結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー brthyyjpbrthyyjp
提出日時 2021-05-23 18:31:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 5,000 ms
コード長 312 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 104,824 KB
最終ジャッジ日時 2023-08-12 22:49:40
合計ジャッジ時間 3,941 ms
ジャッジサーバーID
(参考情報)
judge8 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,396 KB
testcase_01 AC 71 ms
71,296 KB
testcase_02 AC 71 ms
71,300 KB
testcase_03 AC 72 ms
71,304 KB
testcase_04 AC 70 ms
71,316 KB
testcase_05 AC 71 ms
71,360 KB
testcase_06 AC 71 ms
71,536 KB
testcase_07 AC 70 ms
71,304 KB
testcase_08 AC 71 ms
71,260 KB
testcase_09 AC 72 ms
71,380 KB
testcase_10 AC 73 ms
71,520 KB
testcase_11 AC 69 ms
71,512 KB
testcase_12 AC 71 ms
71,340 KB
testcase_13 AC 70 ms
71,320 KB
testcase_14 AC 70 ms
71,496 KB
testcase_15 AC 96 ms
83,192 KB
testcase_16 AC 90 ms
82,396 KB
testcase_17 AC 96 ms
83,772 KB
testcase_18 AC 107 ms
90,728 KB
testcase_19 AC 98 ms
85,232 KB
testcase_20 AC 85 ms
79,648 KB
testcase_21 AC 81 ms
76,216 KB
testcase_22 AC 88 ms
80,248 KB
testcase_23 AC 84 ms
77,840 KB
testcase_24 AC 113 ms
104,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
j = 0
s = set()
ans = 0
for i in range(n):
    while j < n:
        if A[j] not in s:
            s.add(A[j])
            j += 1
        else:
            break
    ans = max(ans, j-i)
    if i == j:
        j += 1
    else:
        s.remove(A[i])
print(ans)
0