Bottles
InterviewTime limit1sMemory limit2048 MB
Given each runner's time in every range, find for each range the maximum number of runners in it at the same moment.
- Level
Medium4 of 10
- Topics
- Sorting, Prefix sum, Simulation
- Solved
- No attempts yet
Statement
In the famous ICPC race, runners will participate. The course is kilometers long and for safety, it is divided into ranges. Each range is one kilometer long and Range () is the interval , which is the section between km and km from the starting point. We will ignore the case where the distance between the starting point and a runner is an integer.
The weather is hot, so the organizers want to supply enough water. They keep a certain number of water bottles in each range. When a runner takes one bottle, they put another one down immediately. The organizers found that the optimal number of bottles in a range equals the maximum number of runners in that range at any moment during the race. Based on each runner's previous records, they estimated how many seconds he or she will spend in each range.
Input
The first line contains two integers and (, ), where is the number of runners and is the length of the course. The following lines each contain positive integers. The -th number on the -th line is the time Runner spends in Range . No runner spends more than seconds in any range.
Output
Print exactly one line. The line contains the number of water bottles for each range, from Range 1 to Range .