結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
syunsuke
|
| 提出日時 | 2019-09-12 00:11:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 265 ms / 3,000 ms |
| コード長 | 620 bytes |
| コンパイル時間 | 652 ms |
| コンパイル使用メモリ | 82,688 KB |
| 実行使用メモリ | 86,544 KB |
| 最終ジャッジ日時 | 2024-07-02 16:56:46 |
| 合計ジャッジ時間 | 8,788 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
Q,K=map(int,input().split())
A=[]
B=[]
import heapq
import sys
input=sys.stdin.readline
heapq.heapify(A)
heapq.heapify(B)
for i in range(Q):
C=list(map(int,input().split()))
#print(C)
if len(C)==1:
if len(B)==0:
print(-1)
else:
a=heapq.heappop(B)
print(a)
else:
if len(A)<K-1:
heapq.heappush(A,-C[1])
elif K==1:
heapq.heappush(B,C[1])
elif A[0]>(-1*C[1]):
heapq.heappush(B,C[1])
else:
heapq.heappush(A,-C[1])
c=heapq.heappop(A)
heapq.heappush(B,-c)
syunsuke