1. Fast and Furious There are N cars on a highway on which cars can move in both the…
- User
- Fast and Furious
There are N cars on a highway on which cars can move in both the directions. Imagine the highway as a number lice
Fach car is located at a specific position von the highway and has a constant velocity v Note that velocities can be both negative and positive. If the velocity is negative, it means that the car will move in the negative direction with speed equal to the absolute value of velocity, whereas if the velocity is positive, it will move in the positive direction
As one can realise, after some time the clas might starts colliding. We want to maximise the time of the first collision under the condition that we can remove at most M of these cars.
Constraints
2≤ N ≤5*10 ^4
1≤M≤N-1
0≤ X ≤10^8
-10^5<=V<=10^5
V≠0
Subtask 1: 50 points N≤1000 Subtask 2: 80 points N <= 5000 Input/Output Format for Custom Testing
Input Format
The first line contains two space-separated integers N and M-the number of cars and the maximum number of cars to remove, respectively.
Then N lines follow, the ith line containing two integers X, and V-the gosition and velocity of the ith car.
Output Format
3 Print a single integer, [Tx105] where T is the time of the first collision between any robots, if the robots will never collide, print-1 instead. (Note (x) denotes the floor(x) which is the largest integer less than or equal to x) sample input 4 1 1 1 2 2 3 -2 4 -3 sample output : 66666
- Assistant