結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー yn
提出日時 2015-09-18 02:37:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 534 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 24,452 KB
最終ジャッジ日時 2024-06-12 22:30:37
合計ジャッジ時間 2,815 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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

num = [False] * 1000001

length = 0
start = 0
best_s = 0
best_l = 0

i = 0
while i < n:
    if not num[a[i]]:
        num[a[i]] = True
        length += 1
        i += 1
    else:
        if start >= n:
            break
        while start < i and a[start] != a[i]:
            num[a[i]] = False
            start += 1
        start += 1
        length = i - start + 1
        i += 1

    best_l = max(best_l, length)
    if best_l == length:
        best_s = start

print(best_l)
0