結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー gemmaro
提出日時 2020-05-01 13:15:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 211 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 24,340 KB
最終ジャッジ日時 2024-11-20 15:01:40
合計ジャッジ時間 3,777 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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