結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー shinichishinichi
提出日時 2021-09-22 18:24:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 291 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 82,604 KB
実行使用メモリ 102,660 KB
最終ジャッジ日時 2024-04-30 17:50:35
合計ジャッジ時間 2,684 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
55,212 KB
testcase_01 AC 37 ms
54,180 KB
testcase_02 AC 37 ms
54,396 KB
testcase_03 AC 36 ms
53,532 KB
testcase_04 AC 38 ms
55,264 KB
testcase_05 AC 37 ms
54,644 KB
testcase_06 AC 37 ms
54,292 KB
testcase_07 AC 38 ms
53,952 KB
testcase_08 AC 39 ms
54,696 KB
testcase_09 AC 40 ms
53,956 KB
testcase_10 AC 39 ms
54,044 KB
testcase_11 AC 38 ms
54,436 KB
testcase_12 AC 39 ms
55,088 KB
testcase_13 AC 37 ms
55,540 KB
testcase_14 AC 38 ms
53,676 KB
testcase_15 AC 75 ms
88,432 KB
testcase_16 AC 70 ms
85,832 KB
testcase_17 AC 76 ms
88,584 KB
testcase_18 AC 99 ms
102,660 KB
testcase_19 AC 77 ms
90,648 KB
testcase_20 AC 59 ms
77,200 KB
testcase_21 AC 52 ms
70,036 KB
testcase_22 AC 63 ms
79,584 KB
testcase_23 AC 57 ms
72,724 KB
testcase_24 AC 87 ms
101,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


N = int(input())
A = list(map(int, input().split()))
ans = 0
counter = defaultdict(int)
r = 0
for l in range(N):
    while r < N and (not counter[A[r]]):
        counter[A[r]] += 1
        r += 1
    ans = max(ans, r-l)
    counter[A[l]] -= 1
print(ans)
0