Codeforces1011B B. Planning The Expedition【模拟】

B. Planning The Expedition

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

input

Copy

4 10
1 5 2 1 1 1 2 5 7 2

output

Copy

2

input

Copy

100 1
1

output

Copy

0

input

Copy

2 5
5 4 3 2 1

output

Copy

1

input

Copy

3 9
42 42 42 42 42 42 42 42 42

output

Copy

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.

题意:m袋食物,每个食物有一个编号,编号相同的就是同种食物,然后同一个人只能吃一种食物,不同的人可以相同或者不同的食物,每人每天吃1个单位的食物,问所有人最多能吃几天

思路:以输入的n个数作为下标,在定义一个数组,将哪一种类的食物数量保存下来,通过每个数除k(1~),从一开始,若都满足除k不小于1,k+1,否则k-1输出k

代码:

#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

int a[108],b[108];
int n,m,t=0,sum=0;
int fin(int k)
{
    sum=0;
    for(int i=1;i<=t;i++)
    {
        sum+=b[i]/k;
    }
    if(sum<n) return (k-1);
    else  return (fin(k+1));
}
int main()
{

    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int temp;
        scanf("%d",&temp);
        a[temp]++;
    }
    for(int i=1;i<=100;i++)
    {
        if(a[i])
        {
           b[++t]=a[i];
        }
    }
    int day=fin(1);
    printf("%d\n",day);
    return 0;
}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不会敲代码的小帅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值