結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー akasia_midori
提出日時 2022-05-03 08:31:10
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 53 ms / 5,000 ms
+ 502µs
コード長 579 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 62 ms
コンパイル使用メモリ 81,532 KB
実行使用メモリ 104,668 KB
最終ジャッジ日時 2026-09-27 02:01:21
合計ジャッジ時間 2,329 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

from collections import deque

input_count = 0
N = int(input())
A=[]
if N!=0:
    A = many_int()

deq = deque([])
sets = set([])
maxs = 0
for a in A:
    if a in sets:
        maxs = max(len(deq),maxs)
        deq.append(a)
        
        while deq:
            temp = deq.popleft()
            if temp==a:
                break
            sets.remove(temp)
                
                
    else:
        sets.add(a)
        deq.append(a)
        


print( max(len(deq),maxs))
0