結果
| 問題 | No.1786 Maximum Suffix Median (Online) |
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:14:19 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,269 bytes |
| コンパイル時間 | 197 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 66,048 KB |
| 最終ジャッジ日時 | 2025-06-12 14:14:26 |
| 合計ジャッジ時間 | 5,847 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 TLE * 1 -- * 24 |
ソースコード
import bisect
def main():
import sys
input = sys.stdin.read
data = input().split()
N = int(data[0])
A_prime = list(map(int, data[1:N+1]))
ans = []
A = []
for i in range(N):
if i == 0:
a = A_prime[i]
else:
a = A_prime[i] ^ ans[-1]
A.append(a)
# Now compute ans[i]
current_list = []
max_median = a
current_list.append(a)
# Iterate backward from i-1 to 0, but keep current_list sorted
for j in range(i-1, -1, -1):
bisect.insort(current_list, A[j])
m = len(current_list)
k = (m + 1) // 2
median = current_list[k-1]
if median > max_median:
max_median = median
else:
# Since the list is being built by adding elements from left (earlier elements),
# adding more elements to the left (which are possibly smaller) may not help.
# So we can break early if the median starts decreasing.
# This is a heuristic and may not always work, but helps in some cases.
pass
ans.append(max_median)
for num in ans:
print(num)
if __name__ == "__main__":
main()
gew1fw