結果

問題 No.649 ここでちょっとQK!
ユーザー mkawa2mkawa2
提出日時 2020-07-19 00:11:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 494 ms / 3,000 ms
コード長 1,110 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 11,028 KB
実行使用メモリ 19,324 KB
最終ジャッジ日時 2023-08-21 05:35:05
合計ジャッジ時間 9,985 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
9,876 KB
testcase_01 AC 30 ms
9,928 KB
testcase_02 AC 30 ms
9,992 KB
testcase_03 AC 365 ms
10,256 KB
testcase_04 AC 490 ms
17,728 KB
testcase_05 AC 360 ms
17,824 KB
testcase_06 AC 358 ms
19,324 KB
testcase_07 AC 30 ms
9,924 KB
testcase_08 AC 30 ms
9,872 KB
testcase_09 AC 30 ms
9,820 KB
testcase_10 AC 31 ms
9,928 KB
testcase_11 AC 31 ms
9,992 KB
testcase_12 AC 223 ms
13,144 KB
testcase_13 AC 212 ms
13,132 KB
testcase_14 AC 214 ms
13,188 KB
testcase_15 AC 237 ms
13,296 KB
testcase_16 AC 214 ms
13,160 KB
testcase_17 AC 268 ms
13,836 KB
testcase_18 AC 294 ms
13,984 KB
testcase_19 AC 323 ms
14,180 KB
testcase_20 AC 345 ms
14,784 KB
testcase_21 AC 377 ms
14,940 KB
testcase_22 AC 396 ms
15,024 KB
testcase_23 AC 422 ms
15,640 KB
testcase_24 AC 451 ms
15,728 KB
testcase_25 AC 484 ms
16,320 KB
testcase_26 AC 494 ms
16,312 KB
testcase_27 AC 32 ms
9,904 KB
testcase_28 AC 32 ms
9,956 KB
testcase_29 AC 33 ms
9,968 KB
testcase_30 AC 209 ms
13,256 KB
testcase_31 AC 233 ms
13,520 KB
testcase_32 AC 30 ms
9,872 KB
testcase_33 AC 30 ms
9,928 KB
testcase_34 AC 29 ms
9,868 KB
testcase_35 AC 30 ms
9,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction
import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

q,k=MI()
hpl=[]
hpr=[]
for _ in range(q):
    t=LI()
    if t[0]==1:
        v=t[1]
        if len(hpl)<k or v<-hpl[0]:heappush(hpl,-v)
        else:heappush(hpr,v)
        if len(hpl)>k:heappush(hpr,-heappop(hpl))
    else:
        if len(hpl)==k:print(-heappop(hpl))
        else:print(-1)
        if len(hpl)<k and hpr:heappush(hpl,-heappop(hpr))
0