結果
問題 |
No.3298 K-th Slime
|
ユーザー |
![]() |
提出日時 | 2025-09-06 14:58:22 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 756 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 82,912 KB |
実行使用メモリ | 98,156 KB |
最終ジャッジ日時 | 2025-09-12 01:52:21 |
合計ジャッジ時間 | 6,945 ms |
ジャッジサーバーID (参考情報) |
judge / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 RE * 4 |
ソースコード
import heapq n, k, q = map(int, input().split()) a = list(map(int, input().split())) h1 = [] h2 = [] for v in a: heapq.heappush(h1, -v) if len(h1) > k: heapq.heappush(h2, -heapq.heappop(h1)) for _ in range(q): query = list(map(int, input().split())) tmp = -heapq.heappop(h1) if query[0] == 1: x = query[1] if tmp > x: heapq.heappush(h1, -x) heapq.heappush(h2, tmp) else: heapq.heappush(h1, -tmp) heapq.heappush(h2, x) elif query[0] == 2: y = query[1] tmp += y tmp2 = heapq.heappop(h2) if tmp2 > tmp: heapq.heappush(h1, -tmp) heapq.heappush(h2, tmp2) else: heapq.heappush(h1, -tmp2) heapq.heappush(h2, tmp) else: print(tmp) heapq.heappush(h1, -tmp)