結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー yvay5cqe
提出日時 2021-08-18 00:58:42
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 226 ms / 5,000 ms
コード長 300 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 23,180 KB
最終ジャッジ日時 2024-11-20 15:08:16
合計ジャッジ時間 2,574 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

l = 0
r = 0
ans = 0
st = set()
while l < n:
    if l > r:
        r = l
    while r < n and a[r] not in st:
        st.add(a[r])
        ans = max(ans, len(st))
        r += 1
    ans = max(ans, len(st))
    st.remove(a[l])
    l += 1
print(ans)
0