#C2711. Minimum Operations to Equalize Sequence
Minimum Operations to Equalize Sequence
Minimum Operations to Equalize Sequence
You are given a sequence of n integers. Your task is to calculate the minimum number of operations required so that the sequence meets the following condition:
If n = 1 then the answer is 1; otherwise, the answer is equal to the number of distinct integers in the sequence.
In other words, if the sequence contains more than one element, compute the number of unique values in the sequence. This value represents the minimum number of operations needed.
Note: Although the problem context may sound like you are performing operations to equalize the sequence, the task is simply to count the distinct elements (with the special case when n = 1).
inputFormat
The input is given from standard input and consists of two lines:
- The first line contains an integer n (the length of the sequence).
- The second line contains n space-separated integers representing the sequence.
outputFormat
Output the minimum number of operations (an integer) to meet the condition described above on a single line to standard output.
## sample5
2 2 1 3 3
3