提出 #75863099


ソースコード 拡げる

from heapq import *
import sys
input = sys.stdin.readline

x = int(input())
A,B = [],[]
heappush(B,-x)
for _ in range(int(input())):
  a,b = map(int,input().split())
  x = -heappop(B)
  if a > x: heappush(A,a)
  else: heappush(B,-a)
  if b > x: heappush(A,b)
  else: heappush(B,-b)
  heappush(B,-x)
  if len(A) > len(B):
    x = heappop(A)
    heappush(B,-x)
  if len(A)+1 < len(B):
    x = -heappop(B)
    heappush(A,x)
  x = -heappop(B)
  print(x)
  heappush(B,-x)

提出情報

提出日時
問題 D - Chalkboard Median
ユーザ Cenix820
言語 Python (PyPy 3.11-v7.3.20)
得点 400
コード長 489 Byte
結果 AC
実行時間 617 ms
メモリ 145824 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 25
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 47 ms 81860 KiB
00_sample_01.txt AC 46 ms 81796 KiB
00_sample_02.txt AC 45 ms 81916 KiB
01_random_00.txt AC 274 ms 135756 KiB
01_random_01.txt AC 246 ms 132916 KiB
01_random_02.txt AC 310 ms 134240 KiB
01_random_03.txt AC 348 ms 136452 KiB
01_random_04.txt AC 349 ms 136836 KiB
01_random_05.txt AC 237 ms 132856 KiB
01_random_06.txt AC 521 ms 135988 KiB
01_random_07.txt AC 611 ms 145092 KiB
01_random_08.txt AC 495 ms 131756 KiB
01_random_09.txt AC 610 ms 144960 KiB
01_random_10.txt AC 455 ms 128408 KiB
01_random_11.txt AC 612 ms 145824 KiB
01_random_12.txt AC 486 ms 140560 KiB
01_random_13.txt AC 508 ms 141264 KiB
01_random_14.txt AC 557 ms 141464 KiB
01_random_15.txt AC 534 ms 140296 KiB
01_random_16.txt AC 496 ms 141604 KiB
01_random_17.txt AC 502 ms 141280 KiB
01_random_18.txt AC 613 ms 145364 KiB
01_random_19.txt AC 617 ms 144988 KiB
01_random_20.txt AC 518 ms 141692 KiB
01_random_21.txt AC 516 ms 141824 KiB