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. java通过IO流复制文件

    package kimoji; import java.io.*; public class FileTest { public static void main(String[] args) thr ...

  2. MySQL->AUTO_INCREMENT[20180516]

    MySQL表格中自增长主键AUTO_INCREMENT使用,实现序列的最简单的方式   创建一个AUTO_INCREMENT自增的表 mysql> create table seq_test( ...

  3. Java使用JodaTime处理时间

    简介 在Java中处理日期和时间是很常见的需求,基础的工具类就是我们熟悉的Date和Calendar,然而这些工具类的api使用并不是很方便和强大,于是就诞生了Joda-Time这个专门处理日期时间的 ...

  4. 运行Delphi XE10的MongoDB例程,测试Delphi插入记录性能

    Delphi XE10支持MongoDB的数据库,提供了个例子restaurants可批量导入数据. 本文对比Delphi例子与MongoDB自带的mongoimport导入批量数据的性能. 步骤: ...

  5. git向码云上提交项目

    git向码云上提交项目 设置账号名字和邮箱 $ git config --global user.name "注册时账号的名字" $ git config --global use ...

  6. 编写DVWA暴力破解High级别的Python脚本

    1. 过程(不查看源代码) 使用burpsuite或者owasp zap抓取数据包,可以看出页面执行过程如下: 首先获取上一次请求的token,然后sleep几秒,最后使用get方法提交验证. 2. ...

  7. Leecode刷题之旅-C语言/python-326 3的幂

    /* * @lc app=leetcode.cn id=326 lang=c * * [326] 3的幂 * * https://leetcode-cn.com/problems/power-of-t ...

  8. Java NIO (1)

    Java NIO (1) 看了下java核心技术这本书 关于nio的部分介绍比较少,而且如果自己写服务器的话nio用的还是比较多,整理一下nio的资料 java中nio主要是三个组件 Buffers ...

  9. PTA基础编程题目集6-3简单求和 (函数题)

    6-3 简单求和 (10 分) 本题要求实现一个函数,求给定的N个整数的和. 函数接口定义: int Sum(int List[],int N) 其中给定整数存放在数组List[]中,正整数N是数组元 ...

  10. 93. Balanced Binary Tree [easy]

    Description Given a binary tree, determine if it is height-balanced. For this problem, a height-bala ...