結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー kokoa1046kokoa1046
提出日時 2018-01-29 19:25:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 548 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 21,500 KB
最終ジャッジ日時 2023-09-03 16:53:57
合計ジャッジ時間 2,249 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
7,864 KB
testcase_02 AC 16 ms
7,784 KB
testcase_03 AC 16 ms
7,740 KB
testcase_04 AC 16 ms
7,832 KB
testcase_05 WA -
testcase_06 AC 16 ms
7,740 KB
testcase_07 AC 16 ms
7,836 KB
testcase_08 WA -
testcase_09 AC 16 ms
7,820 KB
testcase_10 AC 16 ms
7,920 KB
testcase_11 AC 16 ms
7,800 KB
testcase_12 WA -
testcase_13 AC 16 ms
7,868 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
myset =set()
front = 0
back = 0
answer = 1
while front!=N:
    if A[front] in myset:
        #print(A[front])
        tmp=front-back-1
        answer = answer if answer>tmp else tmp
        for i in range(back,front):
            if A[i]==A[front]:
                back=i+1
                break
            myset.remove(A[i])
    else:
        myset.add(A[front])
    front=front+1            
    #print(answer)
#print(back,front)
tmp=front-back
answer = answer if answer>tmp else tmp
print(answer)
0