結果

問題 No.649 ここでちょっとQK!
ユーザー wajima_wataruwajima_wataru
提出日時 2018-03-03 21:28:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 931 ms / 3,000 ms
コード長 328 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 10,716 KB
実行使用メモリ 16,140 KB
最終ジャッジ日時 2023-09-17 21:42:35
合計ジャッジ時間 13,860 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,036 KB
testcase_01 AC 17 ms
7,924 KB
testcase_02 AC 16 ms
7,920 KB
testcase_03 AC 931 ms
8,072 KB
testcase_04 AC 661 ms
16,132 KB
testcase_05 AC 671 ms
15,992 KB
testcase_06 AC 592 ms
16,140 KB
testcase_07 AC 16 ms
7,900 KB
testcase_08 AC 16 ms
7,876 KB
testcase_09 AC 16 ms
7,968 KB
testcase_10 AC 16 ms
7,932 KB
testcase_11 AC 16 ms
8,112 KB
testcase_12 AC 350 ms
11,288 KB
testcase_13 AC 343 ms
11,276 KB
testcase_14 AC 346 ms
11,400 KB
testcase_15 AC 373 ms
11,512 KB
testcase_16 AC 317 ms
11,636 KB
testcase_17 AC 387 ms
12,072 KB
testcase_18 AC 429 ms
12,204 KB
testcase_19 AC 467 ms
12,596 KB
testcase_20 AC 505 ms
12,992 KB
testcase_21 AC 537 ms
13,336 KB
testcase_22 AC 584 ms
13,332 KB
testcase_23 AC 635 ms
13,788 KB
testcase_24 AC 660 ms
14,008 KB
testcase_25 AC 703 ms
14,428 KB
testcase_26 AC 749 ms
14,788 KB
testcase_27 AC 19 ms
8,104 KB
testcase_28 AC 19 ms
8,080 KB
testcase_29 AC 19 ms
8,020 KB
testcase_30 AC 360 ms
11,528 KB
testcase_31 AC 343 ms
11,640 KB
testcase_32 AC 16 ms
7,904 KB
testcase_33 AC 16 ms
8,068 KB
testcase_34 AC 16 ms
8,072 KB
testcase_35 AC 16 ms
7,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

Q, K = map(int, input().split())
low = []
high = []
for _ in range(Q):
    s = input()
    if s[0] == '1':
        n = int(s.split()[1])
        heapq.heappush(low, -n)
        if len(low) == K:
            heapq.heappush(high, -heapq.heappop(low))
    else:
        print(-1 if not high else heapq.heappop(high))
0