Description

Natasha is planning an expedition to Mars for nn people. One of the important tasks is to provide food for each participant.

The warehouse has m daily food packages. Each package has some food type aiai.

Each participant must eat exactly one food package each day. Due to extreme loads, each participant must eat the same food type throughout the expedition. Different participants may eat different (or the same) types of food.

Formally, for each participant j Natasha should select his food type bjbj and each day j-th participant will eat one food package of type bj. The values bjbj for different participants may be different.

What is the maximum possible number of days the expedition can last, following the requirements above?

Input

The first line contains two integers nn and mm (1≤n≤100 1≤m≤100) — the number of the expedition participants and the number of the daily food packages available.

The second line contains sequence of integers a1,a2,…,am (1≤ai≤100), where aiai is the type of ii-th food package.

Output

Print the single integer — the number of days the expedition can last. If it is not possible to plan the expedition for even one day, print 0.

Sample Input

Input
4 10
1 5 2 1 1 1 2 5 7 2
Output
2
Input
100 1
1
Output
0
Input
2 5
5 4 3 2 1
Output
1
Input
3 9
42 42 42 42 42 42 42 42 42
Output
3

Hint

In the first example, Natasha can assign type 1 food to the first participant, the same type 11 to the second, type 55 to the third and type 22 to the fourth. In this case, the expedition can last for 2 days, since each participant can get two food packages of his food type (there will be used 44 packages of type 11, two packages of type 22 and two packages of type 55).

In the second example, there are 100100 participants and only 11 food package. In this case, the expedition can't last even 11 day.

题目意思:有n个人要去参加火星探险活动,准备了m份的食物,编号相同的属于一种食物,每个人每天都要吃一份食物并且必须一直吃一种食物,要是有人没有食物了就返回。问最后所有人一共可以存活多少天。

解题思路:使用map记录各种食物的个数,对能够存活的天数进行枚举暴力,使用迭代器对食物种类进行枚举,判断所有的食物能够支持的人数。

 #include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
map<int,int>mp;
int main()
{
int n,m,i,j,ans,x,p,sum;
scanf("%d%d",&n,&m);
for(i=; i<=m; i++)
{
scanf("%d",&x);
mp[x]++;
}
if(m<n)
{
printf("0\n");
return ;
}
p=m/n;///能活下来的最大天数
map<int,int>::iterator it;
for(i=p; i>; i--) ///对存活的天数进行暴力
{
sum=;
for(it=mp.begin(); it!=mp.end(); it++)///对口粮种类进行暴力
{
sum+=it->second/i;
}
if(sum>=n)///判断最多能支持多少人
{
break;
}
}
printf("%d\n",i);
return ;
}

Planning The Expedition(暴力枚举+map迭代器)的更多相关文章

  1. Coderforces 633D:Fibonacci-ish(map+暴力枚举)

    http://codeforces.com/problemset/problem/633/D D. Fibonacci-ish   Yash has recently learnt about the ...

  2. CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)

    题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000 ...

  3. HNU 12886 Cracking the Safe(暴力枚举)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12886&courseid=274 解题报告:输入4个数 ...

  4. POJ-3187 Backward Digit Sums (暴力枚举)

    http://poj.org/problem?id=3187 给定一个个数n和sum,让你求原始序列,如果有多个输出字典序最小的. 暴力枚举题,枚举生成的每一个全排列,符合即退出. dfs版: #in ...

  5. CCF 201312-4 有趣的数 (数位DP, 状压DP, 组合数学+暴力枚举, 推公式, 矩阵快速幂)

    问题描述 我们把一个数称为有趣的,当且仅当: 1. 它的数字只包含0, 1, 2, 3,且这四个数字都出现过至少一次. 2. 所有的0都出现在所有的1之前,而所有的2都出现在所有的3之前. 3. 最高 ...

  6. HDU - 1248 寒冰王座 数学or暴力枚举

    思路: 1.暴力枚举每种面值的张数,将可以花光的钱记录下来.每次判断n是否能够用光,能则输出0,不能则向更少金额寻找是否有能够花光的.时间复杂度O(n) 2.350 = 200 + 150,买350的 ...

  7. POJ 3080 Blue Jeans (字符串处理暴力枚举)

    Blue Jeans  Time Limit: 1000MS        Memory Limit: 65536K Total Submissions: 21078        Accepted: ...

  8. こだわり者いろはちゃん / Iroha's Obsession (暴力枚举)

    题目链接:http://abc042.contest.atcoder.jp/tasks/arc058_a Time limit : 2sec / Memory limit : 256MB Score ...

  9. Codeforces Round #298 (Div. 2) B. Covered Path 物理题/暴力枚举

    B. Covered Path Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/probl ...

随机推荐

  1. [ERROR] Can't find error-message file '/data/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

    1. MySQL5.7.21启动时报错: [ERROR] Can't find error-message file '/data/mysql/3307/share/errmsg.sys'. Chec ...

  2. Python编程Message: CGI script is not executable ('/cgi-bin/xxxxx.py')

    Message: CGI script is not executable ('/cgi-bin/xxxxx.py'). 今天在练习python服务器端编程时遇到了这个错误,查阅一番最终解决 系统为l ...

  3. md5,md2加密加盐

    数组是没有重写object的toString()方法.byte[].toString()

  4. vue项目使用微信公众号支付总结

    微信公众号支付 1. 使用jssdk调用微信支付,具体查看开发文档: 使用的vuex,在mutations中 wechatPay (state, data) { state.payObject = d ...

  5. 如何安装使用MinDoc搭建个人在线wiki文档

    MinDoc是什么? MinDoc是一个在线的文档管理系统,该系统适用于团队.个人等使用.开发者最初的目的是为了便于公司内部使用,仿照看云开发.有laravel版本以及golang版本.不过larav ...

  6. 高性能MySQL--创建高性能的索引

    关于MySQL的优化,相信很多人都听过这一条:避免使用select *来查找字段,而是要在select后面写上具体的字段. 那么这么做的原因相信大家都应该知道:减少数据量的传输. 但我要讲的是另外一个 ...

  7. laravel Eloquent ORM联合查询出现Class not found,就算在Moel中存在这个类

    今天发现一个坑,在处理Eloquent ORM的联合查询时,一直报错Class 'AdminGroup' not found ,可是我的项目中明明存在这个类,如下 这是我的模型类: 它们的控制器方法: ...

  8. 【四】搭建Nginx服务器

    [任务4]搭建Nginx服务器 [任务4]搭建Nginx服务器 下载Nginx源码包 安装Nginx 解压Nginx安装包 安装Nginx依赖 启动Nginx 安装cgi 下载cgi并解压安装包 编译 ...

  9. wechall MySQL Authentication Bypass II

    首先看看源码 username password分开来验证.但是没做过滤 通常的利用方法是使用union构造已知MD5值的查询. 如果username存在则执行查询,并且为admin.我们用unnio ...

  10. 笔记(assert 断言)

    并发:在同一个时间段交替执行多个任务并行:在同一个时间点同时执行多个任务串行:同时执行的多个任务按顺序执行(换句话说就是一个任务执行完后才能执行下一个任务) #mysql limit用法: selec ...