In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of December 7th
(this exercise will still be available for submission after that deadline, but without couting towards your grade)
[to understand the context of this problem, you should read the class #08 exercise sheet]
This problem is an adapted Mooshak version of a CSES problem.
There is a street of length X whose positions are numbered 0, 1, ..., X. Initially there are no traffic lights, but N sets of traffic lights are added to the street one after another.
Your task is to calculate the length of the longest passage without traffic lights after each addition.
The first input line contains two integers X and N: the length of the street and the number of sets of traffic lights.
Then, the next line contains N integers P1, P2, ..., PN): the position of each set of traffic lights. Each position is distinct.
Print the length of the longest passage without traffic lights after each addition. There should be a single space between each number in the output (but no space at before the first numberor after the last number.
1 ≤ X ≤ 109 | Length of the street | |
1 ≤ N ≤ 2 × 105 | Number of traffic lights | |
0 < Pi < X | Positions of traffic lights |
Example Input | Example Output |
8 3 3 6 2 |
5 3 3 |
Explanation of Example Input