結果

問題 No.649 ここでちょっとQK!
ユーザー skiiskii
提出日時 2018-02-22 23:19:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,345 ms / 3,000 ms
コード長 548 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 93,952 KB
最終ジャッジ日時 2024-04-15 00:17:01
合計ジャッジ時間 22,473 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 1,043 ms
56,448 KB
testcase_04 AC 1,335 ms
92,544 KB
testcase_05 AC 1,197 ms
92,416 KB
testcase_06 AC 1,174 ms
93,952 KB
testcase_07 AC 31 ms
10,752 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 32 ms
10,752 KB
testcase_10 AC 30 ms
10,752 KB
testcase_11 AC 31 ms
10,752 KB
testcase_12 AC 573 ms
49,408 KB
testcase_13 AC 560 ms
49,408 KB
testcase_14 AC 575 ms
49,408 KB
testcase_15 AC 603 ms
49,536 KB
testcase_16 AC 579 ms
49,792 KB
testcase_17 AC 665 ms
53,504 KB
testcase_18 AC 779 ms
57,472 KB
testcase_19 AC 827 ms
61,184 KB
testcase_20 AC 885 ms
65,152 KB
testcase_21 AC 997 ms
68,992 KB
testcase_22 AC 1,045 ms
72,828 KB
testcase_23 AC 1,095 ms
76,672 KB
testcase_24 AC 1,159 ms
80,512 KB
testcase_25 AC 1,268 ms
84,480 KB
testcase_26 AC 1,345 ms
88,448 KB
testcase_27 AC 36 ms
11,008 KB
testcase_28 AC 35 ms
11,136 KB
testcase_29 AC 35 ms
11,008 KB
testcase_30 AC 578 ms
43,648 KB
testcase_31 AC 615 ms
43,904 KB
testcase_32 AC 30 ms
10,752 KB
testcase_33 AC 31 ms
10,880 KB
testcase_34 AC 30 ms
10,880 KB
testcase_35 AC 32 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *
q, k = map(int, input().split())
qle, qgt = [], []
querys = [map(int, input().split())  for _ in range(q)]
for words in querys:
    if next(words) == 1:
        v = next(words)
        if len(qle)<k or v<-qle[0]:
            heappush(qle, -v)
            if len(qle) > k:
                heappush(qgt, -heappop(qle))
        else:
            heappush(qgt, v)
    else:
        if len(qle) < k:
            print(-1)
        else:
            print(-heappop(qle))
            if qgt:
                heappush(qle, -heappop(qgt))
0