結果
| 問題 | No.1786 Maximum Suffix Median (Online) | 
| コンテスト | |
| ユーザー |  Kiri8128 | 
| 提出日時 | 2021-11-23 15:02:05 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 352 ms / 2,000 ms | 
| コード長 | 535 bytes | 
| コンパイル時間 | 331 ms | 
| コンパイル使用メモリ | 81,780 KB | 
| 実行使用メモリ | 98,132 KB | 
| 最終ジャッジ日時 | 2024-07-23 19:42:56 | 
| 合計ジャッジ時間 | 10,513 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 | 
ソースコード
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)))
            
            
            
        