結果
問題 | No.649 ここでちょっとQK! |
ユーザー |
![]() |
提出日時 | 2018-02-04 19:55:59 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,351 ms / 3,000 ms |
コード長 | 779 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 20,352 KB |
最終ジャッジ日時 | 2024-10-08 01:05:34 |
合計ジャッジ時間 | 17,067 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
import heapqQ, K = map(int, input().split())heap_k_least = []heap_other = []size = 0for i in range(Q):query = list(map(int, input().split()))if query[0] == 1:if size < K:heapq.heappush(heap_k_least, -query[1])size += 1elif -heap_k_least[0] > query[1]:heapq.heappush(heap_other, -heapq.heappop(heap_k_least))heapq.heappush(heap_k_least, -query[1])else:heapq.heappush(heap_other, query[1])else:if size >= K:print(-heap_k_least[0])if heap_other:heap_k_least[0] = -heapq.heappop(heap_other)else:heapq.heappop(heap_k_least)size -= 1else:print(-1)