結果

問題 No.1786 Maximum Suffix Median (Online)
ユーザー Kiri8128Kiri8128
提出日時 2021-11-23 15:02:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 419 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 99,012 KB
最終ジャッジ日時 2023-10-01 02:14:37
合計ジャッジ時間 12,187 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,460 KB
testcase_01 AC 75 ms
71,244 KB
testcase_02 AC 76 ms
71,144 KB
testcase_03 AC 78 ms
71,220 KB
testcase_04 AC 77 ms
71,216 KB
testcase_05 AC 77 ms
71,008 KB
testcase_06 AC 76 ms
71,140 KB
testcase_07 AC 75 ms
70,976 KB
testcase_08 AC 419 ms
96,512 KB
testcase_09 AC 312 ms
90,968 KB
testcase_10 AC 313 ms
92,464 KB
testcase_11 AC 289 ms
88,964 KB
testcase_12 AC 374 ms
98,960 KB
testcase_13 AC 339 ms
96,744 KB
testcase_14 AC 281 ms
91,960 KB
testcase_15 AC 300 ms
93,932 KB
testcase_16 AC 307 ms
94,048 KB
testcase_17 AC 286 ms
91,300 KB
testcase_18 AC 392 ms
98,984 KB
testcase_19 AC 400 ms
99,012 KB
testcase_20 AC 408 ms
98,844 KB
testcase_21 AC 384 ms
98,944 KB
testcase_22 AC 399 ms
98,996 KB
testcase_23 AC 302 ms
93,756 KB
testcase_24 AC 251 ms
88,372 KB
testcase_25 AC 337 ms
96,376 KB
testcase_26 AC 254 ms
91,332 KB
testcase_27 AC 241 ms
89,228 KB
testcase_28 AC 264 ms
93,496 KB
testcase_29 AC 79 ms
71,332 KB
testcase_30 AC 77 ms
70,956 KB
testcase_31 AC 279 ms
93,004 KB
testcase_32 AC 350 ms
96,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
class MaxHeapQ():
    def __init__(self):
        self.H = []
    def hpush(self, x):
        heappush(self.H, -x)
    def hpop(self):
        return -heappop(self.H)
    def hmax(self):
        return -self.H[0]

N = int(input())
A = [int(input()) for _ in range(N)]
ANS = [-1] * N
ans = 0
MH = [MaxHeapQ() for _ in range(2)]
for i in range(0, N):
    H = MH[i%2]
    H.hpush(A[i-1])
    H.hpop()
    A[i] ^= ans
    H.hpush(A[i])
    ans = H.hmax()
    ANS[i] = ans
print("\n".join(map(str, ANS)))
0