ログインしてください。
Official
E - 1つだけ/Unique Value Editorial
by
E - 1つだけ/Unique Value Editorial
by
sounansya
map などのデータ構造で各値が何回出現するかを記録し、その中でちょうど \(1\) 回のみ出現する値の個数を数えれば良いです。
実装例(Python3)
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in a:
d[i] += 1
ans = 0
for i, c in d.items():
ans += c == 1
print(ans)
