#P4479. K-th Largest Slope
K-th Largest Slope
K-th Largest Slope
Given n distinct points in the 2D Cartesian coordinate system, every pair of distinct points determines a line. For each such line that has a well-defined slope (i.e. not vertical), sort these lines by their slopes in descending order. Your task is to output the slope of the k-th line in this sorted order after applying the floor function to the slope value.
Note: The floor operation \(\lfloor x \rfloor\) returns the greatest integer less than or equal to \(x\). For example, \(\lfloor 1.5 \rfloor = 1\) and \(\lfloor -1.5 \rfloor = -2\).
Input Format: The first line contains two integers n and k. The following n lines each contain two integers representing the coordinates of a point.
Output Format: Output a single integer which is the floor of the slope of the k-th line when slopes are listed in descending order.
inputFormat
The first line contains two integers n and k (where n is the number of points, and k is the position of the line after sorting based on slope). Each of the following n lines contains two integers x and y, representing the coordinates of a point.
Note: Only consider lines whose slopes exist (i.e. the line is not vertical).
outputFormat
Output a single integer: the result of applying the floor function to the slope of the k-th line from the sorted list.
sample
3 2
0 0
1 1
2 3
1