結果

問題 No.2779 Don't make Pair
ユーザー vwxyz
提出日時 2024-07-14 21:25:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 36,640 KB
最終ジャッジ日時 2024-07-14 21:25:25
合計ジャッジ時間 6,287 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N=int(input())
A=list(map(int,input().split()))
idx=defaultdict(list)
for i in range(N):
    idx[A[i]].append(i)
l,r=0,N-1
for a,lst in idx.items():
    if len(lst)>=3:
        l,r=N,0
    elif len(lst)==2:
        i,j=lst
        l=max(l,i)
        r=min(r,j)
ans_lst=[i+1 for i in range(l,r)]
print(len(ans_lst))
print(*ans_lst)
0