結果

問題 No.2779 Don't make Pair
ユーザー sk4rd
提出日時 2024-06-07 22:05:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 124,372 KB
最終ジャッジ日時 2024-12-26 08:08:43
合計ジャッジ時間 5,777 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
s1, s2 = set([a[0]]), set(a[1:])
t1, t2 = defaultdict(int), defaultdict(int)
t1[a[0]] += 1
for i in range(1, n): t2[a[i]] += 1
ans = []
for i in range(1, n):
    if len(s1) == i and len(s2) == (n-i): ans.append(i)
    if i == n-1: break
    t2[a[i]] -= 1
    t1[a[i]] += 1
    if t2[a[i]] <= 0: s2.remove(a[i])
    s1.add(a[i])
print(len(ans))
print(*ans)
0