Planning The Expedition(CF-1011B)

Problem Description

Natasha is planning an expedition to Mars for n 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 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 n and m (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 i-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.

Examples

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

题意:总共有 n 个人以及 m 个食物,且每个食物都有一个序号,每个人只能选择吃一种序号的食物,如果有一个人没有食物吃就算饿死,求所有人都没有饿死的情况下能存活几天

思路:先按天数从1枚举到100,依次判断每一天的食物是否足够所有人存活,若够就更新最大存活天数,否则输出之前的天数

Source Program

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<ctime>
#include<vector>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define N 10001
#define MOD 1e9+7
#define E 1e-6
#define LL long long
using namespace std;
int a[N];
int bucket[N];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a[i];
        bucket[a[i]]++;
    }
    
    if(n>m)
        cout<<0<<endl;
    else
    {
        int day=0;
        for(int i=1;i<=100;i++)
        {
            int cnt=0;
            for(int j=1;j<=100;j++)
                cnt+=(bucket[j]/i);
                
            if(cnt>=n)
                day=i;
            else
                break;
        }
        cout<<day<<endl;
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值