結果

問題 No.3298 K-th Slime
ユーザー Meso Meso
提出日時 2025-10-10 13:21:07
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 647 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 18,596 KB
最終ジャッジ日時 2025-10-10 13:21:11
合計ジャッジ時間 4,629 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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