結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2020-07-19 00:11:51 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 573 ms / 3,000 ms |
| コード長 | 1,110 bytes |
| コンパイル時間 | 273 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 20,992 KB |
| 最終ジャッジ日時 | 2024-12-14 14:30:11 |
| 合計ジャッジ時間 | 12,461 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
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))
mkawa2