結果

問題 No.2779 Don't make Pair
ユーザー norioc
提出日時 2024-06-07 22:54:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 82,072 KB
実行使用メモリ 107,016 KB
最終ジャッジ日時 2024-12-26 09:25:38
合計ジャッジ時間 4,125 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

N = int(input())
A = list(map(int, input().split()))

rfreq = Counter()
rdup = 0
for i in range(N):
    rfreq[A[i]] += 1
    if rfreq[A[i]] == 2:
        rdup += 1

ans = []
lfreq = Counter()
for i in range(N-1):
    lfreq[A[i]] += 1
    if lfreq[A[i]] == 2:
        break

    rfreq[A[i]] -= 1
    if rfreq[A[i]] == 1:
        rdup -= 1

    if rdup == 0:
        ans.append(i+1)

print(len(ans))
print(*ans)
0