#P14765. [ICPC 2024 Seoul R] Bottles
[ICPC 2024 Seoul R] Bottles
题目描述
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. As the weather is quite hot, the organizers would like to put enough water. They will maintain a certain number of water bottles in each range. When a runner takes one bottle, they will put another immediately. They have found that the optimal number of water bottles could be obtained by calculating the maximum number of runners in that interval during the race. Based on the previous records of each runner, they have estimated how many seconds he/she will spend in each range.
Consider the following example. There are three runners, and the length of the course is six kilometers. The table shows the amount of time runners will spend in each range (in seconds).
| Runner | Range 1 | Range 2 | Range 3 | Range 4 | Range 5 | Range 6 |
|---|---|---|---|---|---|---|
| 1 | 350s | 360s | 370s | 380s | 390s | 400s |
| 2 | 240s | |||||
| 3 | 480s | 520s | 600s | |||
Now we will check the number of runners in each range during the race. Intentionally, the table below is not complete. When you fill the whole table and compute the maximum number of runners for each range, you can see that you need to put three bottles of water in Range 1, two in Range 2 and Range 3, and one in Range 4, Range 5, and Range 6. Note that at , Runner 2 leaves Range 2 and Runner 3 arrives at Range 2, both of which will be ignored as their distance from the starting point is an integer. At , no runner is in Range 1 and in Range 3 and Runner 1 is in Range 2. Then, for example, at , Runner 1 and Runner 3 will be in Range 2.
| Time elapsed | Range 1 | Range 2 | Range 3 | Range 4 | Range 5 | Range 6 |
|---|---|---|---|---|---|---|
| (0s, 240s) | 3 | 0 | 0 | 0 | ||
| (240s, 350s) | 2 | 1 | ||||
| (350s, 480s) | 1 | 2 | ||||
| (480s, 710s) | 0 | 1 | ||||
| (710s, 720s) | 1 | 2 | ||||
| ... | ||||||
Given the number of runners, the length of the course, and the amount of time each runner will spend in each range, write a program to compute the number of bottles to be put in each range.
输入格式
Your program is to read from standard input. The input starts with a line containing two integers, and (, ), where is the number of runners and is the length of the course. In the following lines, the -th line contains positive integers that represent the amount of time Runner will spend in each range. More precisely, the -th number on the line is the time Runner will spend in Range . No runner will spend more than seconds in any range.
输出格式
Your program is to write to standard output. Print exactly one line. The line should contain the numbers of bottles in each range from Range 1 to Range .
3 6
350 360 370 380 390 400
240 240 240 240 240 240
480 480 520 600 600 600
3 2 2 1 1 1
4 5
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
4 4 4 4 4
3 5
1 1 1 1 1
5 5 5 5 5
25 25 25 25 25
3 1 1 1 1