아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Linear Regression

시간 제한5초메모리 제한1024 MB

요약
n개의 점 중 k개를 제거한 뒤 남은 점들로 어떤 직선까지의 최대 수직거리를 최소로 만들고, 그 최솟값을 출력한다.
난이도

보통10점 중 7점

유형
기하, 이분 탐색, 그리디
정답자
아직 제출이 없습니다

문제

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 GG.

Chansu collected data of the form (x_i,y_i)(x\_i, y\_i) from nn persons in GG, where x_ix\_i and y_iy\_i denote the obesity index and the yearly income of the ii-th person, and made an apparent hypothesis:

There is a linear dependency between the obesity and the yearly income of individuals in group GG.

To prove his hypothesis, Chansu tried to find an optimal linear function f\*(x)f^\*(x) with real coefficients such that the error with respect to the collected data is minimized. More specifically, the error of ff with respect to the data is defined to be the maximum of ∣y_i−f(x_i)∣|y\_i - f(x\_i)| over all i=1,…,ni = 1, \dots , n.

However, the result was disappointing because the error of the optimal function f\*(x)f^\*(x) 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 (x_i,y_i)(x\_i, y\_i) as points on the coordinated plane and realized that there are a small number kk 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 kk values from the given data (x_1,y_1),…,(x_n,y_n)\\{(x\_1, y\_1), \dots , (x\_n, y\_n)\\} and prints out the error value, when the number kk is given as part of input.

입력

Your program is to read from standard input. The input starts with a line containing two integers, nn and kk (1≤n≤50,0001 ≤ n ≤ 50\\,000, 0≤k≤min⁡n2,3000 ≤ k ≤ \min{\\{\frac{n}{2}, 300\\}}), where 𝑛𝑛 is the number of collected data values. In each of the following nn lines, each data value (x_i,y_i)(x\_i, y\_i) is given by two integers x_ix\_i and y_iy\_i (−109≤x_i,y_i≤109-10^9 ≤ x\_i, y\_i ≤ 10^9) for i=1,…,ni = 1, \dots , n. 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 zz representing the minimum possible error of a linear function with respect to the data after removing some kk values. Your output zz 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 a−10−6<z<a+10−6a - 10^{-6} < z < a + 10^{-6}, where aa denotes the exact answer.

예제4

  1. 예제 1

    입력
    6 0
    0 0
    5 -1
    9 6
    3 0
    4 2
    3 1
    
    예상 출력
    2.166667
    
  2. 예제 2

    입력
    6 1
    0 0
    5 -1
    9 6
    3 0
    4 2
    3 1
    
    예상 출력
    1.000000
    
  3. 예제 3

    입력
    6 2
    0 0
    5 -1
    9 6
    3 0
    4 2
    3 1
    
    예상 출력
    0.500000
    
  4. 예제 4

    입력
    6 3
    0 0
    5 -1
    9 6
    3 0
    4 2
    3 1
    
    예상 출력
    0.083333