1011B Codeforces - Planning the expedition


1011B Codeforces - Planning the expedition






Solution in C++


#include <bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
typedef long long int lli;

int n,k,sol,t,acc;
map<int ,int> all;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=0;i<k;i++)
    {
        cin>>t;
        all[t]++;
    }
    for(int i=1;i<=101;i++)
    {
        acc=0;
        for(auto u : all)acc+=u.second/i;
        if(acc>=n )sol=i;
    }
    if(n>k)cout<<0;
    else cout<<sol;
    return 0;
}
Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق