結果

問題 No.3298 K-th Slime
ユーザー Meso Meso
提出日時 2025-10-10 13:21:40
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 647 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 82,612 KB
実行使用メモリ 104,636 KB
最終ジャッジ日時 2025-10-10 13:21:45
合計ジャッジ時間 4,682 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n, k, q = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)

for _ in range(q):
    query = list(map(int, input().split()))
    
    if query[0] == 1:
        heapq.heappush(a, query[1])
    
    elif query[0] == 2:
        smallest_k = heapq.nsmallest(k, a)
        if len(smallest_k) < k:
            continue  
        target = smallest_k[-1]
        a.remove(target)
        heapq.heapify(a)  
        heapq.heappush(a, target + query[1])
    
    else:
        smallest_k = heapq.nsmallest(k, a)
        if len(smallest_k) < k:
            print(-1)  
        else:
            print(smallest_k[-1])
0