結果
問題 |
No.3298 K-th Slime
|
ユーザー |
|
提出日時 | 2025-10-05 13:53:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 373 ms / 2,000 ms |
コード長 | 818 bytes |
コンパイル時間 | 373 ms |
コンパイル使用メモリ | 82,776 KB |
実行使用メモリ | 99,764 KB |
最終ジャッジ日時 | 2025-10-05 13:53:55 |
合計ジャッジ時間 | 6,676 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
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 and q_large: 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])