atcoder#ARC087A. [ABC082C] Good Sequence
[ABC082C] Good Sequence
Score : points
Problem Statement
You are given a sequence of positive integers of length , . Your objective is to remove some of the elements in so that will be a good sequence.
Here, an sequence is a good sequence when the following condition holds true:
- For each element in , the value occurs exactly times in .
For example, , and (an empty sequence) are good sequences, while and are not.
Find the minimum number of elements that needs to be removed so that will be a good sequence.
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum number of elements that needs to be removed so that will be a good sequence.
4
3 3 3 3
1
We can, for example, remove one occurrence of . Then, is a good sequence.
5
2 4 1 4 2
2
We can, for example, remove two occurrences of . Then, is a good sequence.
6
1 2 2 3 3 3
0
1
1000000000
1
Remove one occurrence of . Then, is a good sequence.
8
2 7 1 8 2 8 1 8
5