結果
| 問題 |
No.3298 K-th Slime
|
| コンテスト | |
| ユーザー |
sepa38
|
| 提出日時 | 2025-09-06 15:01:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 464 ms / 2,000 ms |
| コード長 | 761 bytes |
| コンパイル時間 | 179 ms |
| コンパイル使用メモリ | 82,156 KB |
| 実行使用メモリ | 97,624 KB |
| 最終ジャッジ日時 | 2025-09-12 01:52:25 |
| 合計ジャッジ時間 | 7,247 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
import heapq
n, k, q = map(int, input().split())
a = list(map(int, input().split()))
h1 = []
h2 = [1<<60]
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)
sepa38