結果
| 問題 | No.3298 K-th Slime |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-05 14:21:24 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 291 ms / 2,000 ms |
| + 515µs | |
| コード長 | 737 bytes |
| 記録 | |
| コンパイル時間 | 231 ms |
| コンパイル使用メモリ | 95,600 KB |
| 実行使用メモリ | 100,864 KB |
| 最終ジャッジ日時 | 2026-07-15 12:12:11 |
| 合計ジャッジ時間 | 6,214 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
import heapq
import bisect
N, K, Q = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ftK = A[: K]
atK = A[K:]
heapq.heapify(atK)
for i in range(Q):
query = list(map(int, input().split()))
if query[0] == 1:
if query[1] >= ftK[-1]:
heapq.heappush(atK, query[1])
else:
heapq.heappush(atK, ftK.pop())
bisect.insort_left(ftK, query[1])
elif query[0] == 2:
slim = ftK.pop() + query[1]
if len(atK) >= 1:
target = heapq.heappop(atK)
if slim <= target:
ftK.append(slim)
heapq.heappush(atK, target)
else:
ftK.append(target)
heapq.heappush(atK, slim)
else:
ftK.append(slim)
else:
print(ftK[-1])