#P8685. [蓝桥杯 2019 省 A] 外卖店优先级
[蓝桥杯 2019 省 A] 外卖店优先级
Description
In the “Bao Le Me” takeaway system, there are takeaway shops, numbered from to . Each shop has a priority value. Initially (at time ), all priorities are .
For every unit of time:
- If a shop has no orders, its priority decreases by , but not below .
- If a shop has orders, its priority does not decrease. Instead, for each order, its priority increases by .
If at some time a shop’s priority is greater than , it will be added to the priority cache. If its priority is less than or equal to , it will be removed from the priority cache.
Given order records within time , compute how many shops are in the priority cache at time .
Input Format
The first line contains integers , , and .
The next lines each contain two integers and , meaning that at time , the shop with number received one order.
Output Format
Output one integer representing the answer.
2 6 6
1 1
5 2
3 1
6 2
2 1
6 2
1
Hint
Sample Explanation
At time , shop ’s priority drops to and is removed from the priority cache; shop ’s priority increases to and is added to the priority cache. Therefore, there is shop (shop ) in the priority cache.
Constraints and Rules
For of the testdata, .
For all testdata, , , .
Lanqiao Cup 2019 Provincial Contest, Group A, Problem G.
Translated by ChatGPT 5
京公网安备 11011102002149号