2017 ICPC beijing E - Cats and Fish
#1631 : Cats and Fish
描述
There are many homeless cats in PKU campus. They are all happy because the students in the cat club of PKU take good care of them. Li lei is one of the members of the cat club. He loves those cats very much. Last week, he won a scholarship and he wanted to share his pleasure with cats. So he bought some really tasty fish to feed them, and watched them eating with great pleasure. At the same time, he found an interesting question:
There are m fish and n cats, and it takes ci minutes for the ith cat to eat out one fish. A cat starts to eat another fish (if it can get one) immediately after it has finished one fish. A cat never shares its fish with other cats. When there are not enough fish left, the cat which eats quicker has higher priority to get a fish than the cat which eats slower. All cats start eating at the same time. Li Lei wanted to know, after x minutes, how many fish would be left.
输入
There are no more than 20 test cases.
For each test case:
The first line contains 3 integers: above mentioned m, n and x (0 < m <= 5000, 1 <= n <= 100, 0 <= x <= 1000).
The second line contains n integers c1,c2 … cn, ci means that it takes the ith cat ci minutes to eat out a fish ( 1<= ci <= 2000).
输出
For each test case, print 2 integers p and q, meaning that there are p complete fish(whole fish) and q incomplete fish left after x minutes.
- 样例输入
-
2 1 1
1
8 3 5
1 3 4
4 5 1
5 4 3 2 1 - 样例输出
-
1 0
0 1
0 3/*
模拟
*/
#include <bits/stdc++.h> #define MAXN 123 using namespace std; struct Node{
int id,val;
Node(){}
Node(int _id,int _val){
id=_id;
val=_val;
}
bool operator < (const Node & other) const {
return val<other.val;
}
};
int m,n,x;
int a[MAXN];
int b[MAXN];
vector<Node>v; inline void init(){
memset(b,,sizeof b);
memset(a,,sizeof a);
v.clear();
} int main(){
// freopen("in.txt","r",stdin);
while(scanf("%d%d%d",&m,&n,&x)!=EOF){
init();
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
for(int i=;i<=x;i++){
int tol=;
for(int j=;j<=n;j++){
if(b[j]==){
tol++;
}
}
if(tol>m){//不够了
if(m>){
v.clear();
for(int j=;j<=n;j++){
if(b[j]==)
v.push_back(Node(j,a[j]));
}
sort(v.begin(),v.end());
for(int j=;j<(int)v.size();j++){
if(m<=)
break;
m--;
b[v[j].id]=a[v[j].id];
}
}
}else{//够
for(int j=;j<=n;j++){//喂鱼
if(b[j]==){
m--;
b[j]=a[j];
}
}
}
for(int j=;j<=n;j++){//吃鱼
b[j]--;
}
}
int res=;
for(int i=;i<=n;i++){
if(b[i]>)
res++;
}
printf("%d %d\n",m,res);
}
return ;
}
2017 ICPC beijing E - Cats and Fish的更多相关文章
- 2017 ICPC beijing F - Secret Poems
#1632 : Secret Poems 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The Yongzheng Emperor (13 December 1678 – ...
- 2017 北京网络赛 E Cats and Fish
Cats and Fish 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They ...
- Cats and Fish HihoCoder - 1631
Cats and Fish HihoCoder - 1631 题意: 有一些猫和一些鱼,每只猫有固定的吃鱼速度,吃的快的猫优先选择吃鱼,问在x秒时有多少完整的鱼和有多少猫正在吃鱼? 题解: 模拟一下. ...
- hihoCoder 1631 Cats and Fish(ACM-ICPC北京赛区2017网络同步赛)
时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They are all happy ...
- hihocoder#1631 : Cats and Fish
Description There are many homeless cats in PKU campus. They are all happy because the students in t ...
- 2017 icpc 沈阳网络赛
cable cable cable Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- Cats and Fish(小猫分鱼吃吱吱吱!)(我觉得是要用贪心的样子!)
炎炎夏日,一堆
- 2017 ICPC 广西邀请赛1004 Covering
Covering Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- 2017 ICPC区域赛(西安站)--- J题 LOL(DP)
题目链接 problem description 5 friends play LOL together . Every one should BAN one character and PICK o ...
随机推荐
- day 2 给程序传递参数
1.如何实现变化name name = "alex" print("欢迎%s前来指导学习"%name) 欢迎alex前来指导学习 2.sys.argv impo ...
- spring源码-开篇
一.写博客也有一段时间了,感觉东西越来越多了,但是自己掌握的东西越来越少了,很多时候自己也在想.学那么多东西,到头来知道的东西越来越少了.是不是很奇怪,其实一点都不奇怪. 我最近发现了一个很大的问题, ...
- android学习十 ActionBar
1.api level大于等于11 支持,或者使用兼容库,但兼容库的问题很多. 2.一个操作栏属于一个活动,并具有其生命周期 3.操作栏分3类:a.选项卡操作栏,b.列表操作栏,c.标准操作栏 4.获 ...
- 阿里云服务器Linux系统安装配置ElasticSearch搜索引擎
近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...
- 【sessionInfo】使用说明
对象:sessionInfo 说明:会话类型操作,此对象是session与cookies的完善版,解决了session异常丢失及cookies文件大小的问题. 注意: 1) 访客的IP地址发生变化时 ...
- CSS让内部元素以相反的顺序显示
代码如下: <div id="main" style=" flex-direction: row-reverse;-webkit-flex-direction: r ...
- 缓存 memcache 小白笔记
W: Memcached是神魔? Q:Memcached是一个自由开源的,高性能,分布式内存对象缓存系统. W:原理图 Q:如下 1浏览器 2 服务器 3 数据库 4 memcac ...
- 《Effective C++》读书笔记 被你忽略的关于构造析构赋值
如果程序员没有定义,那么编译器会默认隐式为你创建一个copy构造函数,一个copy赋值操作符,一个析构函数.另外如果你没有声明任何构造函数,编译器会为你声明一个default构造函数. 但是只有当这些 ...
- Apache——访问控制
Order 指定执行允许访问规则和拒绝访问规则 Deny 定义拒绝访问列表 Allow 定义允许访问列表 Order allow,deny 先执行允许,再执行拒绝 Order deny,allow ...
- HADOOP (十一).安装hbase
下载安装包并解压设置hbase环境变量配置hbase-site.xml启动hbase检测hbase启动情况测试hbase shell 下载安装包并解压 https://mirrors.tuna.tsi ...