AT_abc470_b.Monocolor

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 (1≤i≤N)(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.

有 NN 个球。每个球被涂成 NN 种颜色之一:颜色 11 至颜色 NN。第 ii 个球 (1≤i≤N)(1\le i\le N) 的颜色为 CiC_i。

每次操作中,你可以将任意一个球的颜色更改为 NN 种颜色中的任意一种。

求使所有球颜色相同的最少操作次数。

输入格式

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

NN
C1C_1 C2C_2 …\ldots CNC_N

输入从标准输入给出,格式如下:

NN
C1C_1 C2C_2 …\ldots CNC_N

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    4
    3 1 2 1

    输出#1

    2
  • 输入#2

    5
    3 3 3 3 3

    输出#2

    0
  • 输入#3

    9
    4 2 3 3 4 1 2 7 1

    输出#3

    7

说明/提示

Sample 1 Explanation:
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.

Sample 2 Explanation:
All balls may have the same color from the beginning.

Constraints

  • 1≤N≤1001\le N\le 100
  • 1≤Ci≤N1\le C_i\le N
  • All input values are integers.

样例 1 解释:
通过将第一个球的颜色改为 11,并将第三个球的颜色改为 11,可以使所有球颜色相同。

无法通过修改少于两个球的颜色使所有球颜色相同,因此输出 22。

样例 2 解释:
所有球在初始时可能已经具有相同的颜色。

约束条件

  • 1≤N≤1001\le N\le 100
  • 1≤Ci≤N1\le C_i\le N
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页