103780: [Atcoder]ABC378 A - Pairing
Description
Score : $100$ points
Problem Statement
There are four balls, and the color of the $i$-th ball is $A_i$.
Find the maximum number of times you can perform this operation: choose two balls of the same color and discard both.
Constraints
- Each of $A_1, A_2, A_3, A_4$ is an integer between $1$ and $4$, inclusive.
Input
The input is given from Standard Input in the following format:
$A_1$ $A_2$ $A_3$ $A_4$
Output
Print the maximum number of times the operation can be performed as an integer.
Sample Input 1
2 1 2 1
Sample Output 1
2
The first and third balls both have color $2$, so you can perform the operation to discard the first and third balls together.
Next, the second and fourth balls both have color $1$, so you can perform the operation to discard the second and fourth balls together.
Hence, you can perform a total of two operations.
Sample Input 2
4 4 4 1
Sample Output 2
1
Sample Input 3
1 2 3 4
Sample Output 3
0
There are cases where you cannot perform the operation even once.
Output
得分:$100$分
问题陈述
有四个球,第$i$个球的颜色是$A_i$。
找出你可以执行以下操作的最大次数:选择两个颜色相同的球并丢弃它们。
约束条件
- $A_1, A_2, A_3, A_4$每一个都是介于$1$和$4$(包含$1$和$4$)的整数。
输入
输入从标准输入以下格式给出:
$A_1$ $A_2$ $A_3$ $A_4$
输出
以整数形式打印可以执行操作的最大次数。
示例输入 1
2 1 2 1
示例输出 1
2
第一个和第三个球都是颜色$2$,所以你可以执行操作来同时丢弃这两个球。
接下来,第二个和第四个球都是颜色$1$,所以你可以执行操作来同时丢弃这两个球。
因此,你可以总共执行两次操作。
示例输入 2
4 4 4 1
示例输出 2
1
示例输入 3
1 2 3 4
示例输出 3
0
有些情况下,你甚至不能执行一次操作。