結果
| 問題 |
No.1786 Maximum Suffix Median (Online)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-14 21:16:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 366 ms / 2,000 ms |
| コード長 | 754 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 101,168 KB |
| 最終ジャッジ日時 | 2024-07-23 19:42:46 |
| 合計ジャッジ時間 | 12,196 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd
input = lambda :sys.stdin.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())
def maximum_suffix_median_online(N,A):
if N==1:
return [A[0]]
A[1] ^= A[0]
res = [A[i] for i in range(N)]
que = [[] for p in range(2)]
for i in range(2,N):
A[i] ^= res[i-1]
p = i&1
heappush(que[p],-A[i-1])
heappush(que[p],-A[i-2])
heappop(que[p])
res[i] = max(A[i],-que[p][0])
return res
N = int(input())
A = [int(input()) for i in range(N)]
print(*maximum_suffix_median_online(N,A),sep="\n")