#P8685. [蓝桥杯 2019 省 A] 外卖店优先级

[蓝桥杯 2019 省 A] 外卖店优先级

Description

In the “Bao Le Me” takeaway system, there are NN takeaway shops, numbered from 11 to NN. Each shop has a priority value. Initially (at time 00), all priorities are 00.

For every 11 unit of time:

  • If a shop has no orders, its priority decreases by 11, but not below 00.
  • If a shop has orders, its priority does not decrease. Instead, for each order, its priority increases by 22.

If at some time a shop’s priority is greater than 55, it will be added to the priority cache. If its priority is less than or equal to 33, it will be removed from the priority cache.

Given MM order records within time TT, compute how many shops are in the priority cache at time TT.

Input Format

The first line contains 33 integers NN, MM, and TT.

The next MM lines each contain two integers tsts and idid, meaning that at time tsts, the shop with number idid 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 66, shop 11’s priority drops to 33 and is removed from the priority cache; shop 22’s priority increases to 66 and is added to the priority cache. Therefore, there is 11 shop (shop 22) in the priority cache.

Constraints and Rules

For 80%80\% of the testdata, 1N,M,T100001 \le N, M, T \le 10000.

For all testdata, 1N,M,T1051 \le N, M, T \le 10^5, 1tsT1 \le ts \le T, 1idN1 \le id \le N.

Lanqiao Cup 2019 Provincial Contest, Group A, Problem G.

Translated by ChatGPT 5