結果

問題 No.649 ここでちょっとQK!
ユーザー tktk_snsntktk_snsn
提出日時 2020-07-15 20:22:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 538 ms / 3,000 ms
コード長 538 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 18,560 KB
最終ジャッジ日時 2024-05-02 01:11:59
合計ジャッジ時間 9,709 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 27 ms
10,624 KB
testcase_03 AC 371 ms
10,880 KB
testcase_04 AC 485 ms
18,560 KB
testcase_05 AC 495 ms
18,560 KB
testcase_06 AC 418 ms
18,560 KB
testcase_07 AC 26 ms
10,752 KB
testcase_08 AC 26 ms
10,752 KB
testcase_09 AC 26 ms
10,752 KB
testcase_10 AC 26 ms
10,752 KB
testcase_11 AC 26 ms
10,624 KB
testcase_12 AC 261 ms
13,952 KB
testcase_13 AC 264 ms
13,952 KB
testcase_14 AC 241 ms
14,080 KB
testcase_15 AC 291 ms
14,080 KB
testcase_16 AC 213 ms
14,336 KB
testcase_17 AC 265 ms
14,464 KB
testcase_18 AC 291 ms
14,848 KB
testcase_19 AC 333 ms
15,104 KB
testcase_20 AC 355 ms
15,616 KB
testcase_21 AC 390 ms
15,744 KB
testcase_22 AC 403 ms
16,128 KB
testcase_23 AC 439 ms
16,384 KB
testcase_24 AC 481 ms
16,820 KB
testcase_25 AC 494 ms
17,024 KB
testcase_26 AC 538 ms
17,280 KB
testcase_27 AC 28 ms
10,752 KB
testcase_28 AC 27 ms
10,624 KB
testcase_29 AC 26 ms
10,624 KB
testcase_30 AC 263 ms
14,080 KB
testcase_31 AC 222 ms
14,208 KB
testcase_32 AC 28 ms
10,624 KB
testcase_33 AC 28 ms
10,752 KB
testcase_34 AC 29 ms
10,752 KB
testcase_35 AC 27 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import heapq
input = sys.stdin.readline

Q, K = map(int, input().split())
low = []
high = []
for _ in range(Q):
    query = list(map(int, input().split()))
    if len(query) == 2:
        heapq.heappush(low, -query[1])
        if len(low) > K:
            x = -heapq.heappop(low)
            heapq.heappush(high, x)
    else:
        if len(low) < K:
            print(-1)
        else:
            print(-heapq.heappop(low))
            if high:
                x = heapq.heappop(high)
                heapq.heappush(low, -x)
0