結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー stnkien
提出日時 2020-08-31 22:59:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 145 ms / 5,000 ms
コード長 285 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 23,092 KB
最終ジャッジ日時 2024-11-20 15:02:10
合計ジャッジ時間 2,270 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
S = set()
r = 0
ans = 0
for l in range(N):
    while r < N and A[r] not in S:
        S.add(A[r])
        r += 1
    
    if ans < r-l:
        ans = r-l
    
    if l == r:
        r += 1
    else:
        S.remove(A[l])
print(ans)
0