Problem F
Quadratic Dissonance

Oh no! Both you and your lab partner forgot to complete one part of the latest assignment and it is due in an hour!

The purpose of this lab assignment was to have you analyze some experimental data, find a quadratic function that best describes the data, and report the minimum value that can be taken by this quadratic.

Both you and your partner have tried this part on your own, in order to double-check your answers. Unfortunately, you both found different quadratic functions!

You don’t have time to repeat the experiment. To try and maximize your chances of reporting a value that is close to the minimum (i.e. to get partial credit), you decide to find a value $x$ that minimizes the maximum of your two quadratic functions.

More precisely, your task is the following. Given two quadratic functions $f(x) = x^2 + A\cdot x + B$ and $g(x) = x^2 + C \cdot x + D$ (here $A,B,C,D$ will be given values), you should find a value $x^*$ minimizing the maximum of these two functions. That is, $x^*$ should be chosen to minimize the function $h(x) = \max \{ f(x), g(x)\} $.


Input consists of a single line containing four integers $A, B, C, D$, each lying in the range $[-1\, 000, 1\, 000]$.


Display two values $x^*, h(x^*)$ on a single line where $x^*$ is the point that minimizes the function $h(x) = \max \{ x^2 + A \cdot x + B, x^2 + C \cdot x + D\} $.

Your answer will be accepted if both values are within an absolute or relative error of $10^{-4}$ of the correct answer.

Sample Input 1 Sample Output 1
1 0 0 1
0 1
Sample Input 2 Sample Output 2
2 -1 0 -2
-0.5 -1.75
Sample Input 3 Sample Output 3
3 1 3 -2
-1.5 -1.25
Sample Input 4 Sample Output 4
2 2 2 2
-1 1
Sample Input 5 Sample Output 5
25 -73 -23 41
2.375 -7.984375

Please log in to submit a solution to this problem

Log in