#P9292. [ROI 2018] Robomarathon
[ROI 2018] Robomarathon
Background
Translated from ROI 2018 Day2 T3. Робомарафон (Robomarathon).
Problem Description
There are robot runners in a marathon, numbered . The track has lanes, also numbered . Each runner occupies one lane: runner (or simply ) is in lane (or simply lane ). All lanes have the same distance from start to finish. It is known that runner needs seconds to finish the whole distance.
At the start of each lane there is a starting horn, but it does not play sound. The referee played a prank and turned off the starting horns on some lanes.
When the time comes, all starting horns that are on will send the start signal at the same time (called “firing” below). If lane fires, runner will start immediately.
The start signal propagates at a speed of lane per second. For example, if only lane fires, then after one second runners and will receive the signal and start immediately; after two seconds runners and will receive the signal and start immediately. Suppose runner starts at second , then they will finish at second .
We rank runners by their finishing order. For example, if , , and , then runner and runner are tied for first place, and runner is third.
As you can see, the ranking depends on which starting horns are turned on. Please find, for each runner, their best possible rank or their worst possible rank.
Input Format
The first line contains , .
The next line contains numbers, representing .
Output Format
If , output the best possible rank.
If , output the worst possible rank.
5 1
8 5 5 7 7
3
1
1
2
1
5 2
8 5 5 7 7
5
3
2
4
5
Hint
For all testdata, , .
| Subtask ID | ||
|---|---|---|
In Subtasks and , each test point is worth point, and the total score is the sum.
Translated by ChatGPT 5