#P5381. [THUPC 2019] 不等式
[THUPC 2019] 不等式
Description
Time goes back to June 7, 2017. In the afternoon, the sunlight is just right.
You, in the examination room, keep writing without stopping. Amid the rustling sounds, you fill in an answer sheet meant for your past and future selves.
Just like you have practiced countless times, you jump straight to the last big problem on this math paper. For the either-or question, you directly choose the latter. After quickly skimming the statement, your furrowed brows gradually relax.
“This is in the bag.”
You do not dare to pause for even a moment, and you move one small step closer to your dream.
Given two -dimensional real vectors and , define functions with domain :
$$f_k(x)=\sum_{i=1}^{k} \lvert a_ix+b_i\rvert \quad (k=1,2,\dots,n)$$Now, for each , find the minimum value of over . It can be proven that the minimum always exists.
Input Format
The first line contains an integer , representing the length of the vectors and the number of functions.
The next two lines each contain integers, describing the components of vectors and , separated by spaces.
For all input data, it holds that and .
Output Format
Output lines. The -th line () contains a real number, representing the minimum value of over .
Your output will be considered correct if the absolute error or relative error compared with the standard answer is less than .
2
1 1
1 2
0.00000
1.00000
Hint
Sample Explanation
, which obviously achieves its minimum value at .
. It can be proven that it achieves its minimum value at any point in .
Postscript
Later, the students who took the third national exam paper once again recalled the fear of being dominated by parametric equations.
Copyright Information
From THUPC (THU Programming Contest, Tsinghua University Programming Contest) 2019.
Resources such as solutions can be found at https://github.com/wangyurzee7/THUPC2019.
Translated by ChatGPT 5
京公网安备 11011102002149号