結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー gemmarogemmaro
提出日時 2020-05-01 13:15:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 184 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 24,304 KB
最終ジャッジ日時 2024-04-30 17:44:17
合計ジャッジ時間 3,271 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
22,504 KB
testcase_01 AC 69 ms
22,440 KB
testcase_02 AC 70 ms
22,660 KB
testcase_03 AC 68 ms
22,504 KB
testcase_04 AC 70 ms
22,456 KB
testcase_05 AC 69 ms
22,500 KB
testcase_06 AC 72 ms
22,448 KB
testcase_07 AC 81 ms
22,452 KB
testcase_08 AC 77 ms
22,448 KB
testcase_09 AC 71 ms
22,448 KB
testcase_10 AC 68 ms
22,432 KB
testcase_11 AC 69 ms
22,444 KB
testcase_12 AC 69 ms
22,448 KB
testcase_13 AC 69 ms
22,540 KB
testcase_14 AC 68 ms
22,432 KB
testcase_15 AC 135 ms
23,512 KB
testcase_16 AC 126 ms
23,140 KB
testcase_17 AC 133 ms
23,272 KB
testcase_18 AC 184 ms
24,144 KB
testcase_19 AC 145 ms
24,304 KB
testcase_20 AC 109 ms
23,364 KB
testcase_21 AC 87 ms
23,404 KB
testcase_22 AC 116 ms
23,708 KB
testcase_23 AC 97 ms
23,556 KB
testcase_24 AC 181 ms
23,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import array


def solve(n, d):
    l = r = m = 0
    c = array.array("i", [False] * (10 ** 6 + 1))

    while r < n:
        if c[d[r]]:
            m = max(m, r - l)
            c[d[l]] = False
            l += 1
        else:
            c[d[r]] = True
            r += 1
    return max(m, r - l)


n = int(input())
d = array.array("i", map(int, input().split()))

print(solve(n, d))
0