結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー lllllll88938494lllllll88938494
提出日時 2022-01-10 23:46:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 177 ms / 5,000 ms
コード長 571 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 25,144 KB
最終ジャッジ日時 2024-04-30 17:50:46
合計ジャッジ時間 2,276 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 25 ms
10,752 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 25 ms
10,880 KB
testcase_05 AC 25 ms
10,752 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 25 ms
10,752 KB
testcase_08 AC 25 ms
10,752 KB
testcase_09 AC 26 ms
10,752 KB
testcase_10 AC 24 ms
10,752 KB
testcase_11 AC 26 ms
10,752 KB
testcase_12 AC 25 ms
10,752 KB
testcase_13 AC 25 ms
10,752 KB
testcase_14 AC 24 ms
10,752 KB
testcase_15 AC 109 ms
16,384 KB
testcase_16 AC 96 ms
15,600 KB
testcase_17 AC 103 ms
16,264 KB
testcase_18 AC 170 ms
20,580 KB
testcase_19 AC 121 ms
16,752 KB
testcase_20 AC 73 ms
13,952 KB
testcase_21 AC 49 ms
12,416 KB
testcase_22 AC 82 ms
14,568 KB
testcase_23 AC 56 ms
13,056 KB
testcase_24 AC 177 ms
25,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
ns=list(map(int,input().split()))
dic={}
s=set()
cnt=0
ans=0
r=0

for i in range(n):
    if ns[i] not in dic:
        dic[ns[i]] = 1
        cnt += 1
        ans=max(ans,cnt)
    else:
        dic[ns[i]] += 1
        s.add(ns[i])
        while s:
            if ns[r] in s:
                dic[ns[r]] -= 1
                s=set()
                r+=1
            else:
                dic[ns[r]] -= 1
                if dic[ns[r]] == 0:
                    del dic[ns[r]]
                r+=1
        cnt = (i+1) - r

        
print(ans)
    
            
0