B. Planning The Expedition
题目链接:http://codeforces.com/contest/1011/problem/B
题目大意:
输入的n,m代表n个人,m个包裹。
标准就是 每个人一开始只能选定吃哪一个包裹里的食物,刚开始可以和别人吃一样的,也可以和别人吃不一样的。给出的数据代表编号,问你在满足条件的前提下,最多可以让n个人活多少天。
具体思路:
我们可以计算出 i 天这些食物能活下来的最大人数,然后判断的时候,如果说哪一天活下来的最大人数大于n,输出对应的天数就可以了。
代码;
#include<bits/stdc++.h>
using namespace std;
bool cmp(int t1,int t2)
{
return t1>t2;
}
int main()
{
int a[200];
int n,m;
while(cin>>n>>m)
{
int ans=0;
memset(a,0,sizeof(a));
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,sizeof(b));
for(int i=1; i<=200; i++)
{
// cout<<a[i]<<endl;
int index=0;
for(int j=1; j<=ans; j++)
{
if(a[j]/i)
{
int t=a[j]/i;
index+=t;
}
}
b[i]=index;//i代表天数,index代表这些食物在i天的基础上能供养多少人活下去。
}
for(int i=1; i<=200; i++)
{
if(b[i]>=n)flag=i;
}//如果说,某一天这些食物能活下去的人数大于n,记录一下。
cout<<flag<<endl;
}
return 0;
}
B. Planning The Expedition的更多相关文章
- Planning The Expedition(暴力枚举+map迭代器)
Description Natasha is planning an expedition to Mars for nn people. One of the important tasks is t ...
- Codeforces div2 #499 B. Planning The Expedition 大水题
已经是水到一定程度了QAQ- Code: #include<cstdio> #include<algorithm> #include<cstring> using ...
- CF B. Planning The Expedition
题意:有n个人和m个食物,给出每一个食物的种类,每个人只会吃一种食物,每个人一天吃一个食物,问这n个人可以撑多少天. 分析:因为题目给出的天数范围比较小所以我们可以从1到100天开始枚举,我们判断如果 ...
- 题解 CF1011B Planning The Expedition
Solution 考虑 二分 . 首先要确定二分的对象,显然二分天数较为简单. 每次找到的 \(mid\) 需要判断是否能让整队人吃饱,那就调用一个 check() . 对于 check() ,求出每 ...
- CodeForces - 1015 D.Walking Between Houses
Description Natasha is planning an expedition to Mars for nn people. One of the important tasks is t ...
- CodeForces 1011B
Description Natasha is planning an expedition to Mars for nn people. One of the important tasks is t ...
- Codeforces Round #499 (Div. 2)(1011)
Natasha is planning an expedition to Mars for nn people. One of the important tasks is to provide fo ...
- CodeForces Round #499 Div2
A: Stages 题意: 给你n个字符, 现在需要从中选取m个字符,每个字符的花费为在字母表的第几位,并且如果选了某个字符, 那么下一个选择的字符必须要在字母表的2位之后, 假如选了e 那么 不能选 ...
- 敏捷转型历程 - Sprint3 Planning
我: Tech Leader 团队:团队成员分布在两个城市,我所在的城市包括我有4个成员,另外一个城市包括SM有7个成员.另外由于我们的BA离职了,我暂代IT 的PO 职位.PM和我在一个城市,但他不 ...
随机推荐
- codeforces604B
More Cowbell CodeForces - 604B Kevin Sun wants to move his precious collection of n cowbells from Na ...
- Launch4j Java 转可执行程序工具
launch4j 可以用来将Java应用程序转成Windows本地可执行文件 (.exe).提供了本地弹出屏幕,应用程序图标,JRE搜索或使用绑定的JRE,启动失败反馈,传递命令行参数,ANT编译脚本 ...
- jenkins--svn+Email自动触发1(作业设置)
项目名称设置: svn设置: 触发构建设置: 构建加入sonar-scanner代码扫描: 邮件设置: 邮件触发器配置:
- ELK--filebeat nginx模块
Nginx模块 该nginx模块解析由Nginx HTTP服务器创建的访问和错误日志 . 当你运行这个模块的时候,它会执行一些任务: 设置日志文件的默认路径(但不用担心,可以覆盖默认值) 确保每个 ...
- BZOJ3091城市旅行——LCT区间信息合并
题目描述 输入 输出 样例输入 4 5 1 3 2 5 1 2 1 3 2 4 4 2 4 1 2 4 2 3 4 3 1 4 1 4 1 4 样例输出 16/3 6/1 提示 对于所有数据满足 1& ...
- jQuery之制作简单的轮播图效果
[源代码] 链接:https://pan.baidu.com/s/1XpZ66D9fmSwWX3pCnGBqjA 密码:w104 [整体构思] 这个轮播图使用的是jQuery,所以Js的整体代量比较少 ...
- Codeforces Round #420 (Div. 2) A,B,C
A. Okabe and Future Gadget Laboratory time limit per test 2 seconds memory limit per test 256 megaby ...
- Oracle drop table 和 truncate table对grant授权的影响
[oracle@crl ~]$ rlwrap sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue May 16 14: ...
- MVC中权限的知识点及具体实现代码
一:知识点部分 权限是做网页经常要涉及到的一个知识点,在使用MVC做权限设计时需要先了解以下知识: MVC中Url的执行是按照Controller->Action->View页面,但是我们 ...
- (转)Maven中的DependencyManagement和pluginmanagement
背景:最近在学习maven的多模块构建过程中看到DependencyManagement选项,对这个选项的使用做个记录! 区别与联系 这里介绍一个在父项目中的根结点中声明dependencyManag ...