結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー zutsuzutsu
提出日時 2022-05-15 21:59:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 355 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 10,696 KB
実行使用メモリ 19,816 KB
最終ジャッジ日時 2023-09-03 17:03:32
合計ジャッジ時間 14,927 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,472 KB
testcase_01 AC 15 ms
8,428 KB
testcase_02 AC 15 ms
8,404 KB
testcase_03 AC 15 ms
8,432 KB
testcase_04 AC 15 ms
8,480 KB
testcase_05 AC 15 ms
8,524 KB
testcase_06 AC 15 ms
8,636 KB
testcase_07 AC 15 ms
8,532 KB
testcase_08 AC 14 ms
8,444 KB
testcase_09 AC 15 ms
8,484 KB
testcase_10 AC 15 ms
8,416 KB
testcase_11 AC 15 ms
8,636 KB
testcase_12 AC 14 ms
8,500 KB
testcase_13 AC 16 ms
8,444 KB
testcase_14 AC 15 ms
8,408 KB
testcase_15 AC 859 ms
14,904 KB
testcase_16 AC 734 ms
14,036 KB
testcase_17 AC 891 ms
14,700 KB
testcase_18 AC 1,428 ms
19,816 KB
testcase_19 AC 1,003 ms
15,456 KB
testcase_20 AC 537 ms
11,872 KB
testcase_21 AC 200 ms
10,480 KB
testcase_22 AC 594 ms
12,800 KB
testcase_23 AC 300 ms
10,952 KB
testcase_24 TLE -
権限があれば一括ダウンロードができます

ソースコード

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