結果

問題 No.649 ここでちょっとQK!
ユーザー takakintakakin
提出日時 2020-06-08 21:47:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 531 ms / 3,000 ms
コード長 579 bytes
コンパイル時間 997 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 17,584 KB
最終ジャッジ日時 2023-08-27 04:21:32
合計ジャッジ時間 11,493 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,268 KB
testcase_01 AC 16 ms
8,232 KB
testcase_02 AC 17 ms
8,228 KB
testcase_03 AC 317 ms
8,476 KB
testcase_04 AC 492 ms
16,032 KB
testcase_05 AC 476 ms
15,988 KB
testcase_06 AC 399 ms
17,584 KB
testcase_07 AC 16 ms
8,232 KB
testcase_08 AC 17 ms
8,232 KB
testcase_09 AC 17 ms
8,092 KB
testcase_10 AC 16 ms
8,248 KB
testcase_11 AC 17 ms
8,076 KB
testcase_12 AC 254 ms
11,432 KB
testcase_13 AC 237 ms
11,560 KB
testcase_14 AC 244 ms
11,400 KB
testcase_15 AC 272 ms
11,572 KB
testcase_16 AC 194 ms
11,648 KB
testcase_17 AC 259 ms
12,032 KB
testcase_18 AC 292 ms
12,296 KB
testcase_19 AC 320 ms
12,664 KB
testcase_20 AC 351 ms
12,836 KB
testcase_21 AC 392 ms
13,216 KB
testcase_22 AC 406 ms
13,508 KB
testcase_23 AC 442 ms
13,856 KB
testcase_24 AC 459 ms
14,036 KB
testcase_25 AC 500 ms
14,272 KB
testcase_26 AC 531 ms
14,772 KB
testcase_27 AC 18 ms
8,208 KB
testcase_28 AC 18 ms
8,288 KB
testcase_29 AC 19 ms
8,248 KB
testcase_30 AC 260 ms
11,256 KB
testcase_31 AC 223 ms
11,748 KB
testcase_32 AC 16 ms
8,236 KB
testcase_33 AC 16 ms
8,124 KB
testcase_34 AC 17 ms
8,240 KB
testcase_35 AC 16 ms
8,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
q,k=map(int,input().split())
import heapq
Q1,Q2=[],[]
for _ in range(q):
  A=[int(i) for i in input().split()]
  if A[0]==1:
    a=A[1]
    if len(Q1)<k:
      heapq.heappush(Q1,-a)
    else:
      q1=-heapq.heappop(Q1)
      if q1<=a:
        heapq.heappush(Q1,-q1)
        heapq.heappush(Q2,a)
      else:
        heapq.heappush(Q1,-a)
        heapq.heappush(Q2,q1)
  else:
    if len(Q1)<k:
      print(-1)
    else:
      print(-heapq.heappop(Q1))
      if Q2:
        q2=heapq.heappop(Q2)
        heapq.heappush(Q1,-q2)
0