結果
| 問題 |
No.2372 既視感
|
| コンテスト | |
| ユーザー |
meruuu61779999
|
| 提出日時 | 2023-07-07 21:36:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 2,000 ms |
| コード長 | 1,307 bytes |
| コンパイル時間 | 513 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 77,056 KB |
| 最終ジャッジ日時 | 2024-07-21 17:21:20 |
| 合計ジャッジ時間 | 3,229 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
from collections import deque
N, K, Q = map(int, input().split())
dic = dict()
que = deque()
for _ in range(Q):
t = int(input())
if t == 1:
# 既視感のあるものを追加
s = input()
que.append(s)
if s in dic:
dic[s] += 1
else:
dic[s] = 1
# 既視感のないものをdicから消去する
if len(que) > N:
el = que.popleft()
dic[el] -= 1
if dic[el] == 0:
del dic[el]
elif t == 2:
Ps = []
for _ in range(6):
s, t = input().split()
t = int(t)
if s in dic:
t = min(t, K)
Ps.append((s, t))
time = 0
ans = 0
for s, t in Ps:
if time + t <= 60:
time += t
ans += 1
que.append(s)
if s in dic:
dic[s] += 1
else:
dic[s] = 1
# 既視感のないものをdicから消去する
if len(que) > N:
el = que.popleft()
dic[el] -= 1
if dic[el] == 0:
del dic[el]
else:
break
print(ans)
meruuu61779999