ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Алгоритмы и Структуры Данных > задача:


40. Traffic Lights

Задачи сборника

• 32. Ferris Wheel
• 33. Concert Tickets
• 34. Maximum Subarray Sum
• 35. Stick Lengths
• 36. Missing Coin Sum
• 37. Collecting Numbers
• 38. Playlist
• 39. Towers
• 40. Traffic Lights
• 41. Finding Borders
• 42. Money Sums
• 43. Finding Periods
• 44. Minimal Rotation
• 45. Static Range Sum Queries
• 01. Автобус в Джал
• 03. Новый язык программирования
• 05. Trailing Zeros

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 4000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Сложность Альфа

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.

Input
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.

Output
Print the length of the longest passage without traffic lights after each addition.

Constraints
  • 1≤x≤109
  • 1≤n≤2⋅105
  • 0< p(i) < x

Example
Input:
8 3
3 6 2

Output:
5 3 3

Для отправки решений необходимо выполнить вход.

www.contester.ru