#GYM104617B. Ice Cream Biorhythm
Ice Cream Biorhythm
Description
In MilkLand, the market value of a company, heat index, and UV index all go into the sales of ice cream. According to the MLSE (MilkLand Stock Exchange), these three values are modeled by the polynomial functions $F_1, F_2, F_3, G,$ and $H$ which are functions of the time $x$. The biorhythmic status of ice cream at a particular hour is defined to be the sum of these three values.
Trader Yoneda would like to know an ice cream company's biorhythmic status at a particular hour to determine how well it is doing. In MilkLand, there are 3 companies that dominate the ice cream market. The residual effort that a company is making is defined to be the average of the biorhythmic status of all the companies subtracted from the individual companies' biorhythmic status at a particular hour. For each company, please print "company $i$ not doing well" if it has negative residual, otherwise print "company $i$ doing well" if it has 0 or positive residual $(1 \leq i \leq 3)$.
The first line contains an array of coefficients $a_{13}\:a_{12} \:a_{11}\:a_{10}$ for integers $-10^5 \leq a_{1i} \leq 10^5$ representing the function $F_1(x) = a_{13}x^3+a_{12}x^2+a_{11}x+a_{10}$ for the market value of company 1.
The second line contains an array of coefficients $a_{23}\:a_{22}\: a_{21}\: a_{20}$ for integers $-10^5 \leq a_{2i} \leq 10^5$ representing the function $F_2(x) = a_{23}x^3+a_{22}x^2+a_{21}x+a_{20}$ for the market value of company 2.
The third line contains an array of coefficients $a_{33}\: a_{32}\: a_{31}\: a_{30}$ for integers $-10^5 \leq a_{3i} \leq 10^5$ representing the function $F_3(x) = a_{33}x^3+a_{32}x^2+a_{31}x+a_{30}$ for the market value of company 3.
The fourth line has the array of coefficients $b_3\: b_2\: b_1\: b_0$ for integers $-10^5 \leq b_i \leq 10^5$ denoting the function for the UV index $G(x) = b_3x^3+b_2x^2+b_1x+b_0$.
The fifth line has the array of coefficients $c_3\: c_2\: c_1\: c_0$ for integers $-10^5 \leq c_i \leq 10^5$ denoting the function for the heat index $H(x) = c_3x^3+c_2x^2+c_1x+c_0$.
The last line gives a particular hour $d$ for some integer $0 \leq d \leq 10^5$.
It is guaranteed that no biorhythmic value will have an absolute value greater than $10^9$.
Please print 3 separate lines, one per company.
For each line i $(1\leq i \leq 3)$, print "company i not doing well" if the company has a negative residual at hour $d$, else "company i doing well" if it has 0 or positive residual.
Input
The first line contains an array of coefficients $a_{13}\:a_{12} \:a_{11}\:a_{10}$ for integers $-10^5 \leq a_{1i} \leq 10^5$ representing the function $F_1(x) = a_{13}x^3+a_{12}x^2+a_{11}x+a_{10}$ for the market value of company 1.
The second line contains an array of coefficients $a_{23}\:a_{22}\: a_{21}\: a_{20}$ for integers $-10^5 \leq a_{2i} \leq 10^5$ representing the function $F_2(x) = a_{23}x^3+a_{22}x^2+a_{21}x+a_{20}$ for the market value of company 2.
The third line contains an array of coefficients $a_{33}\: a_{32}\: a_{31}\: a_{30}$ for integers $-10^5 \leq a_{3i} \leq 10^5$ representing the function $F_3(x) = a_{33}x^3+a_{32}x^2+a_{31}x+a_{30}$ for the market value of company 3.
The fourth line has the array of coefficients $b_3\: b_2\: b_1\: b_0$ for integers $-10^5 \leq b_i \leq 10^5$ denoting the function for the UV index $G(x) = b_3x^3+b_2x^2+b_1x+b_0$.
The fifth line has the array of coefficients $c_3\: c_2\: c_1\: c_0$ for integers $-10^5 \leq c_i \leq 10^5$ denoting the function for the heat index $H(x) = c_3x^3+c_2x^2+c_1x+c_0$.
The last line gives a particular hour $d$ for some integer $0 \leq d \leq 10^5$.
It is guaranteed that no biorhythmic value will have an absolute value greater than $10^9$.
Output
Please print 3 separate lines, one per company.
For each line i $(1\leq i \leq 3)$, print "company i not doing well" if the company has a negative residual at hour $d$, else "company i doing well" if it has 0 or positive residual.
1 -18 99 -162
1 -22 119 -98
1 -18 104 -192
1 0 11 -6
1 -12 44 -48
5
company 1 not doing well
company 2 doing well
company 3 not doing well