結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー zaki_chemtech
提出日時 2020-07-10 10:11:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 322 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,204 KB
実行使用メモリ 99,680 KB
最終ジャッジ日時 2024-11-20 15:01:53
合計ジャッジ時間 2,206 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())

a = list(map(int,input().split()))

head = 0

check = {a[0]:0}

ans = 0

for tail in range(1,n):
    if a[tail] in check and head <= check[a[tail]]:
        ans = max(ans, tail-head)
        head = check[a[tail]]+1    

    check[a[tail]] = tail
    #print(ans,tail,head)
ans = max(ans, n-head)

print(ans)
0