#P14728. [ICPC 2022 Seoul R] Linear Regression
[ICPC 2022 Seoul R] Linear Regression
题目背景
An extra 5 second time limit is provided.
题目描述
Chansu is a graduate student at University of ICPC, working in a laboratory for his master’s degree. His research theme is to reveal a relation between the obesity and the yearly income of individuals in a certain group G.
Chansu collected data of the form from persons in G, where and denote the obesity index and the yearly income of the -th person, and made an apparent hypothesis:
There is a linear dependency between the obesity and the yearly income of individuals in group G.
To prove his hypothesis, Chansu tried to find an optimal linear function with real coefficients such that the error with respect to the collected data is minimized. More specifically, the error of with respect to the data is defined to be the maximum of over all .
However, the result was disappointing because the error of the optimal function was unexpectedly big. This means that his hypothesis cannot be proven in this way.
Chansu tried to figure out the reason of the big errors. One day, he plotted the data as points on the coordinated plane and realized that there are a small number of points that are unusually far from the others, so the error of the optimal function can be drastically reduced after removing them.
You, as a friend of Chansu, would love to help Chansu. Write a program that finds an optimal linear function minimizing the error after removing some values from the given data and prints out the error value, when the number is given as part of input.
输入格式
Your program is to read from standard input. The input starts with a line containing two integers, and (, ), where is the number of collected data values. In each of the following lines, each data value is given by two integers and () for . You can assume that no three of them are collinear when plotting them in the coordinated plane.
输出格式
Your program is to write to standard output. Print exactly one line. The line should contain a real number representing the minimum possible error of a linear function with respect to the data after removing some values. Your output should be in the format that consists of its integer part, a decimal point, and its fractional part, and will be decided to be “correct” if it holds that , where denotes the exact answer.
6 0
0 0
5 -1
9 6
3 0
4 2
3 1
2.166667
6 1
0 0
5 -1
9 6
3 0
4 2
3 1
1.000000
6 2
0 0
5 -1
9 6
3 0
4 2
3 1
0.500000
6 3
0 0
5 -1
9 6
3 0
4 2
3 1
0.083333