栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

CodeForces - 1003A Polycarp‘s Pockets

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

CodeForces - 1003A Polycarp‘s Pockets

A. Polycarp’s Pockets
time limit per test1 second
memory limit per test256 megabytes

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

问题链接:CodeForces - 1003A Polycarp’s Pockets
问题简述:(略)
问题分析:(略)
AC的C++语言程序如下:


#include 

using namespace std;

const int A = 100;
int cnt[A + 1];

int main()
{
    int n, a, maxcnt = 0;
    scanf("%d", &n);
    memset(cnt, 0, sizeof cnt);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a);
        maxcnt = max(maxcnt, ++cnt[a]);
    }
    printf("%dn", maxcnt);

    return 0;
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/767932.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号