結果
問題 |
No.1786 Maximum Suffix Median (Online)
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:20:44 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,001 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 82,776 KB |
実行使用メモリ | 122,248 KB |
最終ジャッジ日時 | 2025-03-20 20:22:09 |
合計ジャッジ時間 | 5,540 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 TLE * 1 -- * 24 |
ソースコード
import sys def main(): input = sys.stdin.read().split() N = int(input[0]) a_prime = list(map(int, input[1:N+1])) ans = [] A = [] for i in range(N): if i == 0: a_i = a_prime[i] else: a_i = a_prime[i] ^ ans[-1] A.append(a_i) max_med = a_i elements = [] # Check the last 200 elements (empirically chosen) for j in range(i, max(-1, i - 200), -1): elements.append(A[j]) if len(elements) > 200: # Limit the elements considered to avoid TLE break sorted_elements = sorted(elements) m = len(sorted_elements) k = (m + 1) // 2 - 1 # 0-based index current_med = sorted_elements[k] if current_med > max_med: max_med = current_med ans.append(max_med) for val in ans: print(val) if __name__ == "__main__": main()