B. 单色 / Monocolor

    传统题 1000ms 256MiB

单色 / Monocolor

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

There are NN balls. Each ball is painted in one of NN colors: color 11 through color NN. The color of the ii-th ball (1iN)(1\le i\le N) is CiC_i.

In one operation, you can change the color of any one ball to any of the NN colors.

Find the minimum number of operations required to make all the balls the same color.

Constraints

  • 1N1001\le N\le 100
  • 1CiN1\le C_i\le N
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

$N$
$C_1$ $C_2$ $\ldots$ $C_N$

Output

Output the answer.

4
3 1 2 1
2

By changing the color of the first ball to 11 and the color of the third ball to 11, you can make all the balls the same color.

It is impossible to make all the balls the same color by changing the colors of fewer than two balls, so output 22.

5
3 3 3 3 3
0

All balls may have the same color from the beginning.

9
4 2 3 3 4 1 2 7 1
7

ABC470 赛后模拟赛 ✅

未参加
状态
已结束
规则
IOI
题目
7
开始于
2026-8-10 17:00
结束于
2026-8-17 17:00
持续时间
168 小时
主持人
参赛人数
82