CF# 499 div2 B. Planning The Expedition

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.

Examples

扫描二维码关注公众号,回复: 2497444 查看本文章

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

Note

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个人m个食物,每个食物都有种类,每个人只能吃一种食物(无论哪一种),求最多能活多少天。

思路:很简单的一道题,,,,做的时候样例凑过了,但是wa了,题目意思读不懂,不友好。枚举可存活的天数,依次判断食物的份数,若满足就更新最大存活天数。

代码如下:

#include <iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int num[120];
int main()
{
    int n,m;
    memset(num,0,sizeof(num));
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int x;
        scanf("%d",&x);
        num[x]++;
    }
    int ans=0;
    for(int i=1;i<=100;i++)//枚举存活天数 
    {
        int sum=0;
        for(int j=1;j<=100;j++)
        {
            sum+=(num[j]/i);//多少份食物 
        }
        if(sum>=n)//满足条件更新天数 
            ans=i;
        else
            break;
    }
    printf("%d\n",ans);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/PleasantlY1/article/details/81233297