結果

問題 No.649 ここでちょっとQK!
ユーザー MineMine
提出日時 2022-03-02 16:16:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,119 ms / 3,000 ms
コード長 597 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 10,712 KB
実行使用メモリ 16,284 KB
最終ジャッジ日時 2023-09-23 08:51:50
合計ジャッジ時間 18,150 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,988 KB
testcase_01 AC 16 ms
8,088 KB
testcase_02 AC 16 ms
7,988 KB
testcase_03 AC 1,119 ms
8,088 KB
testcase_04 AC 782 ms
16,156 KB
testcase_05 AC 785 ms
16,236 KB
testcase_06 AC 707 ms
16,284 KB
testcase_07 AC 16 ms
8,128 KB
testcase_08 AC 16 ms
7,988 KB
testcase_09 AC 16 ms
8,092 KB
testcase_10 AC 16 ms
8,084 KB
testcase_11 AC 15 ms
8,132 KB
testcase_12 AC 428 ms
11,312 KB
testcase_13 AC 417 ms
11,404 KB
testcase_14 AC 414 ms
11,400 KB
testcase_15 AC 454 ms
11,428 KB
testcase_16 AC 381 ms
11,544 KB
testcase_17 AC 455 ms
12,020 KB
testcase_18 AC 508 ms
12,304 KB
testcase_19 AC 556 ms
12,700 KB
testcase_20 AC 619 ms
12,832 KB
testcase_21 AC 667 ms
13,132 KB
testcase_22 AC 692 ms
13,480 KB
testcase_23 AC 764 ms
13,908 KB
testcase_24 AC 808 ms
13,992 KB
testcase_25 AC 829 ms
14,588 KB
testcase_26 AC 894 ms
14,756 KB
testcase_27 AC 19 ms
8,036 KB
testcase_28 AC 19 ms
8,024 KB
testcase_29 AC 19 ms
8,140 KB
testcase_30 AC 435 ms
11,596 KB
testcase_31 AC 406 ms
11,760 KB
testcase_32 AC 16 ms
8,120 KB
testcase_33 AC 16 ms
8,028 KB
testcase_34 AC 16 ms
8,056 KB
testcase_35 AC 16 ms
8,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

q, k = map(int, input().split())
k_elements = [] #max
tmp = [] #min
for _ in range(q):
    que = list(map(int, input().split()))
    if que[0] == 1:
        v = que[1]
        heapq.heappush(k_elements, -v)
        if len(k_elements) > k:
            maxv = -heapq.heappop(k_elements)
            heapq.heappush(tmp, maxv)
    else:
        if len(k_elements) != k:
            print(-1)
        else:
            maxv = -heapq.heappop(k_elements)
            print(maxv)
            if tmp:
                minv = heapq.heappop(tmp)
                heapq.heappush(k_elements, -minv)
0