思路:
1.最外层循环模拟真实时间线,内层第一个循环和第二个检验是否有订单,有则dic.value(优先级数)加2,无则减1.
2.内层第三个循环用于检验这N家店中哪些需要离开优先级哪些需要加入优先级。
3. n,m,t,ts,i_d等价于题意中的N,MT,ts,id,这个dic字典用于存储N家店个个店家的优先级数值,priority则用于存储在优先级的店家的ID号。
n = int(input())
m = int(input())
t = int(input())
ts = []
i_d = []
dic = {}
priority = []
for x in range(1,n+1):
dic[str(x)] = 0
for x in range(m):
ts.append(int(input()))
i_d.append(int(input()))
for time in range(1,max(ts)+1):
b = {}
for time_1,index in zip(ts,i_d):
if time_1 == time:
b[str(index)] = 1
dic[str(index)] += 2
for key in dic.keys():
if key not in b.keys() and dic[str(key)] > 0:
dic[str(key)] -= 1
for identity,value in dic.items():
if value > 5:
priority.append(identity)
elif value <= 3 and identity in priority:
priority.remove(identity)
if time == t:
print(len(priority))
break