AT_abc470_b.Monocolor
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are N balls. Each ball is painted in one of N colors: color 1 through color N. The color of the i-th ball (1≤i≤N) is Ci.
In one operation, you can change the color of any one ball to any of the N colors.
Find the minimum number of operations required to make all the balls the same color.
有 N 个球。每个球被涂成 N 种颜色之一:颜色 1 至颜色 N。第 i 个球 (1≤i≤N) 的颜色为 Ci。
每次操作中,你可以将任意一个球的颜色更改为 N 种颜色中的任意一种。
求使所有球颜色相同的最少操作次数。
输入格式
The input is given from Standard Input in the following format:
N
C1 C2 … CN
输入从标准输入给出,格式如下:
N
C1 C2 … CN
输出格式
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 1 and the color of the third ball to 1, 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 2.
Sample 2 Explanation:
All balls may have the same color from the beginning.
Constraints
- 1≤N≤100
- 1≤Ci≤N
- All input values are integers.
样例 1 解释:
通过将第一个球的颜色改为 1,并将第三个球的颜色改为 1,可以使所有球颜色相同。
无法通过修改少于两个球的颜色使所有球颜色相同,因此输出 2。
样例 2 解释:
所有球在初始时可能已经具有相同的颜色。
约束条件
- 1≤N≤100
- 1≤Ci≤N
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?