結果
| 問題 | No.3298 K-th Slime |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-05 13:53:00 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 302 ms / 2,000 ms |
| + 481µs | |
| コード長 | 818 bytes |
| 記録 | |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 95,880 KB |
| 実行使用メモリ | 107,520 KB |
| 最終ジャッジ日時 | 2026-07-15 11:47:09 |
| 合計ジャッジ時間 | 6,140 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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])