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 ...
随机推荐
- CF 1042 F. Leaf Sets
F. Leaf Sets http://codeforces.com/contest/1042/problem/F 题意: 将所有的叶子节点分配到尽量少的集合,一个可行的集合中两两叶子节点的距离< ...
- 微信小程序—day02
全局配置 在app.json中,对小程序进行全局配置.官方文档 tabBar是对底部/顶部导航栏的配置,图片的icon 大小限制为40kb,建议尺寸为 81px * 81px 去阿里矢量图网站,找到图 ...
- 微信小程序入门学习之事件 事件对象 冒泡非冒泡事件(1)
这关于事件的学习,可以自己复制到微信开发者工具上自己运行试试. 首先这里有两个文件.js 和.wxml 文件 首先给出.js文件下代码 // pages/news/news.js Page({ /** ...
- 干货来袭:Redis5.0支持的新功能说明
Redis5.0支持的新特性说明 本文内容来自华为云帮助中心 华为云DCS的Redis5.x版本继承了4.x版本的所有功能增强以及新的命令,同时还兼容开源Redis5.x版本的新增特性. Stream ...
- vmware安装64位系统“此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态”的问题
虚拟机使用的是VMware Workstation,并且首次在虚拟机体验64 位系统.在新建好虚拟机,运行时候就出现了VMware Workstation 的提醒:此主机支持 Intel VT-x,但 ...
- Docker: 如何修改 Docker 的镜像存储位置
我用的阿里云的服务器, 但是系统盘只有20G, 默认 Docker 的镜像文件是安装在/var/lib 目录下的, 这样的话我根本装不了太多的镜像... 这个必须得改改... 搜了下, 解决方案如下: ...
- 压力测试工具-webbench
简述 偶然情况下看到一款性能测试工具webbench,看着挺不错的记录一下安装过程,在以后项目上线过程中可以压一压一些页面的并发情况,对项目性能有个大致的了解. 原理 webbench首先fork出多 ...
- TCP系列40—拥塞控制—3、慢启动和拥塞避免概述
本篇中先介绍一下慢启动和拥塞避免的大概过程,下一篇中将会给出多个linux下reno拥塞控制算法的wireshark示例,并详细解释慢启动和拥塞避免的过程. 一.慢启动(slow start) 一个T ...
- Windows 7中安装Solr7
最新忙里偷闲,研究一下了Lucene.Net,发现操作比较繁琐,同比相似的功能,感觉Solr比较简单,容易使用.不过由于Solr使用的是Java的环境,对于.Net开发的人员来说,还是比较陌生,搭配环 ...
- Swagger Authorization:bearer <token>
1.添加如下代码 /** * * @SWG\SecurityScheme( * securityDefinition="Bearer", * type="apiKey&q ...