結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー ynyn
提出日時 2015-09-18 02:53:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 175 ms / 5,000 ms
コード長 538 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 24,664 KB
最終ジャッジ日時 2024-04-30 17:43:28
合計ジャッジ時間 2,447 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
18,672 KB
testcase_01 AC 34 ms
18,560 KB
testcase_02 AC 36 ms
18,568 KB
testcase_03 AC 35 ms
18,560 KB
testcase_04 AC 34 ms
18,556 KB
testcase_05 AC 33 ms
18,488 KB
testcase_06 AC 32 ms
18,576 KB
testcase_07 AC 32 ms
18,500 KB
testcase_08 AC 35 ms
18,568 KB
testcase_09 AC 35 ms
18,520 KB
testcase_10 AC 32 ms
18,504 KB
testcase_11 AC 33 ms
18,512 KB
testcase_12 AC 31 ms
18,508 KB
testcase_13 AC 34 ms
18,496 KB
testcase_14 AC 34 ms
18,532 KB
testcase_15 AC 111 ms
22,676 KB
testcase_16 AC 103 ms
22,048 KB
testcase_17 AC 110 ms
22,488 KB
testcase_18 AC 175 ms
24,072 KB
testcase_19 AC 121 ms
23,624 KB
testcase_20 AC 81 ms
21,668 KB
testcase_21 AC 54 ms
20,084 KB
testcase_22 AC 84 ms
22,000 KB
testcase_23 AC 62 ms
20,672 KB
testcase_24 AC 165 ms
24,664 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[start]] = 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