Planning The Expedition(codeforces 1011B)

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 ai.

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.

题解:每个人一开始只能选定吃哪一个包裹里的食物,刚开始可以和别人吃一样的,也可以和别人吃不一样的。给出的数据代表编号,问你在满足条件的前提下,最多可以让n个人活多少天。我们可以计算出 第i 天这些食物能活下来的最大人数,然后判断的时候,如果说哪一天活下来的最大人数大于n,输出对应的天数就可以了。(暴力天数)

代码如下:

#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <ctime>
#define maxn 320007
#define N 200005
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define eps 0.000000001
#define read(x) scanf("%d",&x)
#define put(x) printf("%d\n",x)
#define memset(x,y) memset(x,y,sizeof(x))
#define Debug(x) cout<<x<<" "<<endl
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
using namespace std;
typedef long long ll;
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int a[200];
    int n,m;
    while(cin>>n>>m)
    {
        int ans=0;
        memset(a,0);
        for(int i=1; i<=m; i++)
        {
            int t;
            cin>>t;
            if(a[t]==0)
            {
                ans++;
            }
            a[t]++;
        }
        sort(a+1,a+101,cmp);
        int b[210];
        int maxx=-1;
        int num=0;
        int flag=0;
        memset(b,0);
        for(int i=1; i<=200; i++)
        {
            int index=0;
            for(int j=1; j<=ans; j++)
            {
                if(a[j]/i)
                {
                    int t=a[j]/i;
                    index+=t;
                }
            }
            b[i]=index;
        }
        for(int i=1; i<=200; i++)
        {
            if(b[i]>=n)
                flag=i;
        }
        cout<<flag<<endl;
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值