結果
問題 |
No.3298 K-th Slime
|
ユーザー |
|
提出日時 | 2025-10-05 13:50:37 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 806 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,348 KB |
実行使用メモリ | 100,204 KB |
最終ジャッジ日時 | 2025-10-05 13:50:45 |
合計ジャッジ時間 | 6,515 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 RE * 4 |
ソースコード
from sys import stdin def input(): return stdin.readline().rstrip("\n") n, k, qc = map(lambda s_: int(s_), input().split()) a = tuple(map(lambda s_: int(s_), input().split())) from heapq import heappop, heappush q_large = [] q_small = [] def push(x): heappush(q_small, -x) while len(q_small) > k: x = heappop(q_small) x = -x heappush(q_large, x) def pop_k(): x = heappop(q_small) x = -x while len(q_small) < k: nx = heappop(q_large) heappush(q_small, -nx) return x for ai in a: push(ai) for _ in range(qc): ty, *rem = map(lambda s_: int(s_), input().split()) if ty == 1: x, = rem push(x) if ty == 2: y, = rem x = pop_k() push(x + y) if ty == 3: print(-q_small[0])