結果
問題 |
No.3298 K-th Slime
|
ユーザー |
👑 ![]() |
提出日時 | 2025-10-05 13:54:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 453 ms / 2,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,400 KB |
実行使用メモリ | 91,624 KB |
最終ジャッジ日時 | 2025-10-05 13:54:45 |
合計ジャッジ時間 | 7,909 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
import heapq N,K,Q = map(int,input().split()) A = list(map(int,input().split())) L = [] R = [] for lp in range(N+Q): if lp < N: query = "1 " + str(A[lp]) else: query = input() if query[0] == "1": _,x = map(int,query.split()) if len(L) < K or -L[0] > x: heapq.heappush(L,-x) else: heapq.heappush(R,x) elif query[0] == "2": _,y = map(int,query.split()) x = -1 * heapq.heappop(L) heapq.heappush(R,x+y) else: print (-1 * L[0]) while len(L) > K: y = -1 * heapq.heappop(L) heapq.heappush(R,y) while len(L) < K and len(R) > 0: y = heapq.heappop(R) heapq.heappush(L,-y)