落谷CF1003A Polycarp's Pockets

题目描述

Polycarp has n n n coins, the value of the i i i -th coin is ai a_i ai​ . Polycarp wants to distribute all the coins between his pockets, but he cannot put two coins with the same value into the same pocket.

For example, if Polycarp has got six coins represented as an array a=[1,2,4,3,3,2] a = [1, 2, 4, 3, 3, 2] a=[1,2,4,3,3,2] , he can distribute the coins into two pockets as follows: [1,2,3],[2,3,4] [1, 2, 3], [2, 3, 4] [1,2,3],[2,3,4] .

Polycarp wants to distribute all the coins with the minimum number of used pockets. Help him to do that.

输入输出格式

输入格式:

The first line of the input contains one integer n n n ( 1≤n≤100 1 \le n \le 100 1≤n≤100 ) — the number of coins.

The second line of the input contains n n n integers a1,a2,…,an a_1, a_2, \dots, a_n a1​,a2​,…,an​ ( 1≤ai≤100 1 \le a_i \le 100 1≤ai​≤100 ) — values of coins.

输出格式:

Print only one integer — the minimum number of pockets Polycarp needs to distribute all the coins so no two coins with the same value are put into the same pocket.

输入输出样例

输入样例#1: 复制

6
1 2 4 3 3 2

输出样例#1: 复制

2

输入样例#2: 复制

1
100

题意:找出相同的数输出

思路:看代码

#include<bits/stdc++.h>
using namespace std;
int a[108],temp,maxn,n;
int main()
{

        scanf("%d",&n);
        for(int i=0;i<n;i++)
        {
            scanf("%d",&temp);
            a[temp]++;
            maxn=max(maxn,a[temp]);
        }
        printf("%d\n",maxn);

    return 0;
}

猜你喜欢

转载自blog.csdn.net/sunpeishuai/article/details/81315933