結果
問題 |
No.3009 Union-Find でつながろう!
|
ユーザー |
![]() |
提出日時 | 2025-06-12 19:57:08 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 625 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 81,808 KB |
実行使用メモリ | 67,020 KB |
最終ジャッジ日時 | 2025-06-12 19:58:21 |
合計ジャッジ時間 | 3,462 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 27 |
ソースコード
import sys def main(): n = int(sys.stdin.readline()) if n == 0: print(0) return a = list(map(int, sys.stdin.readline().split())) max_len = 0 left = 0 last_occurrence = {} for right in range(n): current_num = a[right] if current_num in last_occurrence and last_occurrence[current_num] >= left: left = last_occurrence[current_num] + 1 last_occurrence[current_num] = right current_len = right - left + 1 if current_len > max_len: max_len = current_len print(max_len) if __name__ == "__main__": main()