結果

問題 No.3009 Union-Find でつながろう!
ユーザー gew1fw
提出日時 2025-06-12 20:01:20
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 499 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,088 KB
実行使用メモリ 67,084 KB
最終ジャッジ日時 2025-06-12 20:04:57
合計ジャッジ時間 2,984 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n == 0:
    print(0)
else:
    a = list(map(int, input().split()))
    max_len = 0
    left = 0
    last_occurrence = {}
    for right in range(len(a)):
        current = a[right]
        if current in last_occurrence and last_occurrence[current] >= left:
            left = last_occurrence[current] + 1
        last_occurrence[current] = right
        current_length = right - left + 1
        if current_length > max_len:
            max_len = current_length
    print(max_len)
0