結果
問題 |
No.649 ここでちょっとQK!
|
ユーザー |
![]() |
提出日時 | 2018-02-22 23:39:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,159 ms / 3,000 ms |
コード長 | 523 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 20,224 KB |
最終ジャッジ日時 | 2024-10-04 07:53:53 |
合計ジャッジ時間 | 17,214 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
from heapq import * q, k = map(int, input().split()) qle, qgt = [], [] for _ in range(q): words = map(int, input().split()) if next(words) == 1: v = next(words) if len(qle) < k: heappush(qle, -v) elif v < -qle[0]: heappush(qgt, -heappushpop(qle, -v)) else: heappush(qgt, v) else: if len(qle) < k: print(-1) elif qgt: print(-heapreplace(qle, -heappop(qgt))) else: print(-heappop(qle))