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 mm 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 jj Natasha should select his food type bjbj and each day jj-th participant will eat one food package of type bjbj. 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≤1001≤n≤100, 1≤m≤1001≤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,…,ama1,a2,…,am (1≤ai≤1001≤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 11 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 22 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.

对存活天数进行暴力。

判断该天数能否成立的条件是,对水果的种类数进行暴力,判断所有的水果一共能支持多少人。

注意STL容器map 的使用。

 #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
const double e=exp();
const int N = ; #define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r map<int,int> mp;
int main()
{
int n,m,i,p,j;
int x;
scanf("%d%d",&n,&m);
for(i=;i<=m;i++)
{
scanf("%d",&x);
mp[x]++;
}
if(m<n)
printf("0\n");
else
{
p=m/n;
map<int,int>::iterator it1;
for(i=p;i>;i--)
{
int sum=;
for(it1=mp.begin();it1!=mp.end();it1++)
{
sum+=it1->second/i;
}
if(sum>=n)
break;
}
printf("%d\n",i);
}
return ;
}

CodeForces 1011B的更多相关文章

  1. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  2. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  3. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  4. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  5. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  6. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  7. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  8. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

  9. CodeForces - 148D Bag of mice

    http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...

随机推荐

  1. MySQL 备份和恢复 理论知识

    为什么要备份 数据无价   制定备份策略的注意点 1:可容忍丢失多少数据     2:恢复需要在多长时间内完成     3:备份的对象   数据.二进制日志和InnoDB的事务日志.SQL代码(存储过 ...

  2. 【php】set_include_path和get_include_path用法详解

    目的:在框架中方便加载文件 参考:http://blog.sina.com.cn/s/blog_4ce89f200100twbl.html 如果我们没有设置这个值,可能我们需要写一些完全的路径:    ...

  3. p2 形状

    形状是物理引擎进行碰撞模拟计算的依据,是刚体最基本的属性. P2中使用Shape类来表示形状,通过刚体的addShape()方法,将形状添加到刚体中之后, 就可以随着刚体的移动.旋转不断更新,并进行碰 ...

  4. 洛谷 P5078 Tweetuzki 爱军训

    题目连接 很明显,1e6的范围,要么nlgn要么O(n) nlgn的话可能会想到借助一些数据结构,我并没有想到这种做法 对于这种题,O(n)的做法要么是线性递推,要么就应该是贪心了 考虑这道题我们怎么 ...

  5. 转载乙醇大师的appium简明教程

    appium简明教程(11)——使用resource id定位(仅支持安卓4.3以上系统) 乙醇 2014-06-28 21:01 阅读:16406 评论:21 appium简明教程(10)——控件定 ...

  6. SpringBoot web 小项目

    Spring Boot 整合 Thymeleaf 完整 Web 案例 原创出处  作者:泥瓦匠BYSocket 希望转载,保留摘要,谢谢! Thymeleaf 是一种模板语言.那模板语言或模板引擎是什 ...

  7. Atom实用配置插件for C++

    autocomplete-clang  自动补全 autocomplete for C/C++/ObjC using clang autocomplete-python 自动补全 Python pac ...

  8. 解析C#彩色图像灰度化算法的实现代码详解

    http://www.jb51.net/article/37067.htm public static Bitmap MakeGrayscale(Bitmap original)        {   ...

  9. 把一个文件中所有文件名或者文件路径读取到一个txt文件,然后在matlab中读取

    链接: http://blog.csdn.net/dreamgchuan/article/details/51113295 dir /on/b/s  这个读取的是这样的格式:

  10. STM32自动生成精美图案

    http://note.youdao.com/noteshare?id=65f237225624d22fe18f4aaaeec8db07