結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2024-07-13 18:39:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 918 bytes |
| コンパイル時間 | 441 ms |
| コンパイル使用メモリ | 82,384 KB |
| 実行使用メモリ | 67,264 KB |
| 最終ジャッジ日時 | 2024-07-13 18:39:35 |
| 合計ジャッジ時間 | 4,652 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 31 |
ソースコード
from sortedcontainers import SortedList
from collections import defaultdict
S = SortedList([])
N, Q = map(int, input().split())
dic1 = defaultdict(int)
dic2 = defaultdict(int)
ans = []
for _ in range(Q):
t, *sr = input().split()
if t == "1":
s, r = sr
r = int(r)
dic1[s] = r
dic2[s] = 1
S.add((1, -r, s))
tmp = []
if N < len(S):
a, b, s = S.pop(-1)
ans.append(s)
elif t == "2":
x = int(sr[0])
N = max(0, N - x)
tmp = []
while N < len(S):
a, b, s = S.pop(-1)
tmp.append((b, s))
tmp.sort(reverse=True)
for t, s in tmp:
ans.append(s)
else:
s, x = sr
x = int(x)
N += x
if dic2[s] == 1:
S.remove((1, -dic1[s], s))
S.add((0, -dic1[s], s))
dic2[s] = 0
for s in ans:
print(s)
ntuda