結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー zutsu
提出日時 2022-05-15 21:59:02
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 355 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 27,332 KB
最終ジャッジ日時 2024-06-12 22:40:27
合計ジャッジ時間 15,790 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N = int(input())
A = list(map(int, input().split()))
ans = 0
ct = 0
q = deque()

for a in A:
    if a not in q:
        q.append(a)
        ct += 1
    else:
        ans = max(ans, ct)
        while q[0] != a:
            q.popleft()
            ct -= 1
        q.popleft()
        q.append(a)
ans = max(ans, ct)
print(ans)
0