結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー ynyn
提出日時 2015-09-18 02:37:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 534 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 10,572 KB
実行使用メモリ 22,204 KB
最終ジャッジ日時 2023-09-03 16:52:49
合計ジャッジ時間 3,013 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 28 ms
15,700 KB
testcase_02 AC 27 ms
15,728 KB
testcase_03 AC 27 ms
15,712 KB
testcase_04 AC 26 ms
15,852 KB
testcase_05 WA -
testcase_06 AC 27 ms
15,752 KB
testcase_07 AC 26 ms
15,676 KB
testcase_08 AC 26 ms
15,696 KB
testcase_09 AC 27 ms
15,756 KB
testcase_10 AC 26 ms
15,692 KB
testcase_11 AC 27 ms
15,668 KB
testcase_12 AC 26 ms
15,740 KB
testcase_13 WA -
testcase_14 AC 27 ms
15,748 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 176 ms
22,204 KB
権限があれば一括ダウンロードができます

ソースコード

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