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 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.
Sample Input
4 10
1 5 2 1 1 1 2 5 7 2
2
100 1
1
0
2 5
5 4 3 2 1
1
3 9
42 42 42 42 42 42 42 42 42
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.
对存活天数进行暴力。
判断该天数能否成立的条件是,对水果的种类数进行暴力,判断所有的水果一共能支持多少人。
注意STL容器map 的使用。
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
const double e=exp();
const int N = ; #define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r map<int,int> mp;
int main()
{
int n,m,i,p,j;
int x;
scanf("%d%d",&n,&m);
for(i=;i<=m;i++)
{
scanf("%d",&x);
mp[x]++;
}
if(m<n)
printf("0\n");
else
{
p=m/n;
map<int,int>::iterator it1;
for(i=p;i>;i--)
{
int sum=;
for(it1=mp.begin();it1!=mp.end();it1++)
{
sum+=it1->second/i;
}
if(sum>=n)
break;
}
printf("%d\n",i);
}
return ;
}
CodeForces 1011B的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- CodeForces - 148D Bag of mice
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- 软工网络15团队作业4——Alpha阶段敏捷冲刺-5
一.当天站立式会议照片: 二.项目进展 昨天已完成的工作: 日期等细致信息的处理,对添加账单日期化. 明天计划完成的工作: 完成对账单的编辑,删除等操作,以及开始服务器的编写工作 工作中遇到的困难: ...
- C#获取当前路径的方法如下
1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径. 2. System.Environm ...
- 【.Net】vs2017 自带发布工具 ClickOnce发布包遇到的问题
一.遇到的问题 在安装了vs2017 社区版(Community)之后 想打包安装程序(winform) 还是想用之前的 installshield来打包 发现居然打不了,在官网查了 ins ...
- java 类型转型
- 51nod 1503 猪和回文(多线程DP)
虚拟两个点,一个从左上角开始走,一个从右下角开始走,定义dp[i][j][k]表示走了i步后,第一个点横向走了j步,第二个点横向走了k步后形成的回文方法种数. 转移方程显然可得,然后滚动数组搞一搞. ...
- AtCoder Grand Contest 019 B: Reverse and Compare
题意: 给出一个字符串,你可以选择一个长度大于等于1的子串进行翻转,也可以什么都不做.只能翻转最多一次. 问所有不同的操作方式得到的字符串中有多少个是本质不同的. 分析 tourist的题妙妙啊. 首 ...
- python 序列化 pickle shelve json configparser
1. 什么是序列化 我们把变量从内存中变成可存储或传输的过程称之为序列化. 序列化之后,就可以把序列化后的内容写入磁盘,或者通过网络传输到别的机器上. 反过来,把变量内容从序列化的对象重新读到内存里称 ...
- 《Unix网络编程卷1:套接字联网API》读书笔记
第一部分:简介和TCP/IP 第1章:简介 第2章:传输层:TCP.UDP和SCTP TCP:传输控制协议,复杂.可靠.面向连接协议 UDP:用户数据报协议,简单.不可靠.无连接协议 SCTP:流控制 ...
- String Typing CodeForces - 954B
题意: 给一个字符串,可以复制某一段字符,问最少需要多少步能将其输出,比如abcabcd,先输入abc然后再赋值abc再输入d就只需要5步. 复制的这段字符 必须是从字符串的0位置开始复制的 而且只 ...
- [AT2064] [agc005_f] Many Easy Problems
题目链接 AtCoder:https://agc005.contest.atcoder.jp/tasks/agc005_f 洛谷:https://www.luogu.org/problemnew/sh ...