Parking Garage

4.4

45 votes
Problem

Let’s say you have a parking garage near your house. It has N columns (indexed 0 to N-­1) where you can park N vehicles. When all the vehicles are parked they will be given tokens with numbers on them.Assume all the vehicles leave the garage at the same time. This process continues for M times.

At the end of the day, you need to find the greatest number on the token in each division.

The tokens will be given as follows: For each M, a value of the index will be given where the first vehicle will be parked. That first vehicle will be given token number 0. All the vehicles that come later will be parked either to the right of it or to the left of it and its token number will be 1 greater than the previous car’s token.

Input: The first line contains the number of test cases T. Each Test case contains two space separated integers N and M. Next M lines denote the index where the first token is given each time all the N vehicles are parked.

Output: For each test case output a single line with N space separated integers which are the largest numbers of the tokens given in the corresponding division.

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?