Codeforces1003A——Polycarp's Pockets

Polycarp has n coins, the value of the i-th coin is 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], he can distribute the coins into two pockets as follows: [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.
Input
The first line of the input contains one integer n (1≤n≤100) — the number of coins.
The second line of the input contains n integers a1,a2,…,an (1≤ai≤100) — values of coins.
Output
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.
Examples
Input
6
1 2 4 3 3 2
Output
2
Input
1
100
Output
1

暑假练习第二天
这题思路就是找出出现次数最多的
代码:

#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=105;
int a[MAXN];
int main(void){
    int n;
    int t;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        a[t]++;
    }
    int Max=0;
    for(int i=1;i<=100;i++){
        if(a[i]>Max){
            Max=a[i];
        }
    }
    printf("%d\n",Max);
    return 0;
}
全部评论

相关推荐

11-28 17:58
门头沟学院 Java
美团 JAVA开发 n×15.5
牛客786276759号:百度现在晋升很难的 而且云这块的业务没美团好 你看百度股价都跌成啥样了
点赞 评论 收藏
分享
Bug压路:老哥看得出来你是想多展示一些项目,但好像一般最多两个就够了😂页数一般一页,多的也就2页;这些项目应该是比较同质化的,和评论区其他大佬一样,我也觉得应该展示一些最拿手的(质量>数量)😁😁😁专业技能部分也可以稍微精简一些
点赞 评论 收藏
分享
10-30 23:23
已编辑
中山大学 Web前端
去B座二楼砸水泥地:这无论是个人素质还是专业素质都👇拉满了吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务