結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー brthyyjpbrthyyjp
提出日時 2021-05-23 18:31:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 71 ms / 5,000 ms
コード長 312 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 97,956 KB
最終ジャッジ日時 2024-04-30 17:50:20
合計ジャッジ時間 2,008 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,520 KB
testcase_01 AC 33 ms
53,040 KB
testcase_02 AC 32 ms
52,132 KB
testcase_03 AC 32 ms
52,444 KB
testcase_04 AC 33 ms
52,828 KB
testcase_05 AC 32 ms
53,444 KB
testcase_06 AC 33 ms
53,268 KB
testcase_07 AC 33 ms
52,108 KB
testcase_08 AC 33 ms
52,732 KB
testcase_09 AC 31 ms
53,160 KB
testcase_10 AC 32 ms
52,408 KB
testcase_11 AC 33 ms
52,128 KB
testcase_12 AC 33 ms
53,136 KB
testcase_13 AC 33 ms
53,476 KB
testcase_14 AC 34 ms
52,344 KB
testcase_15 AC 58 ms
79,284 KB
testcase_16 AC 51 ms
76,492 KB
testcase_17 AC 56 ms
80,036 KB
testcase_18 AC 70 ms
89,648 KB
testcase_19 AC 60 ms
82,024 KB
testcase_20 AC 49 ms
71,656 KB
testcase_21 AC 42 ms
65,876 KB
testcase_22 AC 52 ms
73,672 KB
testcase_23 AC 45 ms
68,488 KB
testcase_24 AC 71 ms
97,956 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