Let,
N = 5
TARGET = 12
POSITION = [10, 8, 0, 5, 3]
SPEED = [2, 4, 1, 1, 3]
Answer:- 3 ( Car 1 and 2 arrive at the same time, car 3 arrives at a different time, car 4 and car 5 arrive at a different time, so there is a total of 3 different arrival times).
The first line contains a single integer ‘T’ representing the number of test cases. Then each test case follows.
The first line of each test case contains an integer ‘N’ and ‘D’ denoting the number of cars and the point of destination respectively.
The next line of every test case contains ‘N’ integers containing the POSITIONS of the ith car.
The next line of every test case contains ‘N’ integers containing the SPEEDS of the ith car.
For each test case, print an integer denoting the number of unique arrivals of the cars.
The output of each test case should be printed in a separate line.
You are not required to print anything, it has already been taken care of. Just implement the function.
1 <= T <= 5
1 <= N <= 10^5
1 <= D <= 10^6
1 <= POSITIONS[i] <= 10^6
1 <= SPEED[i] <= 10^6
Note:- The positions of the cars are pairwise distinct.
Time Limit: 1 sec
We can observe that if a car can overtake any car in front then it will arrive with that car and will not have a unique arrival time. So we check whether a particular car can overtake any car (i.e if the time required by that car is less than the time taken by the cars in front of it) in front or not. If yes, we increase the count else not.