In a car race, there are N cars 1,2 ... N where the ith car is moving with a speed of (N - i + 1). All the cars are moving in the same direction.
The current position of the cars is Xi. Determine the time at which the first overtake takes place.
Note: Overtake is defined as the place when a car crosses another car that is ahead of it.
Input format
- Each test contains multiple test cases.
- The first line contains the number of test cases T.
- The first line of each test case contains two space-separated integers N and M representing the number of cars and the length of the circular path.
- The second line of each test case contains N integers where the ith integer is Xi representing the position of the ith car on the track.
Output format
For each test case, print a single line containing one integer representing the time at which the first overtake takes place.
Constraints
The first overtake takes place at time t = 1.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor