#P4479. [BJWC2018] 第k大斜率

    ID: 3414 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2018树状数组离散化北京概率论,统计

[BJWC2018] 第k大斜率

Description

On the 2D Cartesian plane, there are nn distinct points. Any two distinct points determine a line. Among all lines whose slopes are defined, sort them by slope in descending order and find the slope of the kk-th line.

To avoid precision errors, please output the floor of the slope. (For example: 1.5=1\lfloor 1.5 \rfloor = 1, 1.5=2\lfloor -1.5 \rfloor = -2.)

Input Format

The first line contains two positive integers nn and kk.
Each of the next nn lines contains two integers xi,yix_i, y_i, the coordinates of a point.

Output Format

Output one line containing an integer: the floor of the kk-th largest slope.

4 1
-1 -1
2 1
3 3
1 4
2

Hint

[Sample Explanation]

The slopes of the lines that meet the requirement are 3,12,23,1,2,52-3, -\frac{1}{2}, \frac{2}{3}, 1, 2, \frac{5}{2}.

[Constraints]

Let MM be the number of lines whose slopes are defined.

  • For 10%10\% of the testdata, 1n101 \le n \le 10.
  • For 20%20\% of the testdata, 1n1001 \le n \le 100, xi,yi103|x_i|, |y_i| \le 10^3.
  • For 30%30\% of the testdata, 1n10001 \le n \le 1000.
  • For 40%40\% of the testdata, 1n50001 \le n \le 5000.
  • For another 20%20\% of the testdata, k=1k = 1.
  • For another 20%20\% of the testdata, 1xi,yi1031 \le x_i, y_i \le 10^3.
  • For 100%100\% of the testdata, 1n1000001 \le n \le 100000, 1kM1 \le k \le M, xi,yi108|x_i|, |y_i| \le 10^8.

Translated by ChatGPT 5