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. jQuery属性操作之.attr()

    目录 .attr() 调用形式:$("xxx").attr(name) 调用形式:$("xxx").attr(name,value); 调用形式:$(" ...

  2. 弄清Spark、Storm、MapReduce的这几点区别才能学好大数据

    很多初学者在刚刚接触大数据的时候会有很多疑惑,比如对MapReduce.Storm.Spark三个计算框架的理解经常会产生混乱. 哪一个适合对大量数据进行处理?哪一个又适合对实时的流数据进行处理?又该 ...

  3. java-spark的各种常用算子的写法

    通常写spark的程序用scala比较方便,毕竟spark的源码就是用scala写的.然而,目前java开发者特别多,尤其进行数据对接.上线服务的时候,这时候,就需要掌握一些spark在java中的使 ...

  4. 树莓派3B+学习笔记:7、挂载exfat格式U盘

    树莓派的官方系统,默认不支持exfat格式U盘挂载. 插入exfat格式U盘会出现以下错误提示: 安装exfat-fuse后可以正常识别,需要在命令行执行以下命令,按“y”键回车确认: sudo ap ...

  5. Chino 操作系统开发日志 (1) - 为 IoT 而生

    引言 很多人都听说过 IoT (物联网)这个词,越来越多的人在装修时开始选择智能家居,很多人也购买智能音箱做智能家居控制,想必未来一定是 AI + 物联网的时代. 一种技术要发展并走向成熟必须要降低门 ...

  6. golang 项目实战简明指南

    原文地址 开发环境搭建 golang 的开发环境搭建比较简单,由于是编译型语言,写好 golang 源码后,只需要执行 go build 就能将源码编译成对应平台(本文中默认为 linux)上的可执行 ...

  7. IC设计笔试面试小问题总结(随时更新)-IC设计笔记(三)

    都是一些细节性问题,放在一起记忆,一问一答的形式,有任何问题欢迎文章上方微博讨论,多思多想. 1.What makes the difference between Run time and CPU ...

  8. 20155233 2016-2017-2《Java程序设计》课程总结

    20155233 2016-2017-2<Java程序设计>课程总结 每周作业链接汇总 预备作业1:预习去写博客,如何达到理想的师生关系. 预备作业2:对自己C语言的学习进行了解与认识. ...

  9. removeAttribute与removeAttributeNode的区别

    1.removeAttributeNode() 方法删除指定的属性,并以 Attr Node 对象返回被删除的属性. 例: <!DOCTYPE html><html><b ...

  10. win32api 找不到指定的模块

    pywin32 安装后 import win32api 出现ImportError: DLL load failed: 找不到指定的模块 解决方法: 拷贝 C:\Python26\Lib\site-p ...