hihocoder#1631 : Cats and Fish
Description
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.
Input
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).
Output
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.
Sample Input
2 1 1
1
8 3 5
1 3 4
4 5 1
5 4 3 2 1
Sample Output
1 0
0 1
0 3 用b记录每个猫的状态,正在吃鱼是1,否则是0
当当前的时间能被猫的吃鱼时间整除,就表示当前的猫吃完了一条鱼
用num表示吃完的鱼的条数,cnt表示剩的鱼的条数
#include <bits/stdc++.h> using namespace std;
int a[];
int b[];
int main(){
int m,n,x;
while(cin>>m>>n>>x){
memset(b,,sizeof(b));
for(int i=;i<=n;i++){
cin>>a[i];
}
sort(a+,a+n+);
int num=,cnt=m;
for(int i=;i<=x;i++){
for(int j=;j<=n;j++){
if(b[j]==){
cnt--;
b[j]=;
}
if(i%a[j]==&&b[j]==){
b[j]=;
num++;
}
if(cnt==)
break;
}
if(cnt==)
break;
}
int ans=;
for(int i=;i<=n;i++){
if(b[i]==)
ans++;
}
cout<<m-num-ans<<' '<<ans<<endl;
}
}
hihocoder#1631 : Cats and Fish的更多相关文章
- hihoCoder 1631 Cats and Fish(ACM-ICPC北京赛区2017网络同步赛)
时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They are all happy ...
- 2017 ICPC beijing E - Cats and Fish
#1631 : Cats and Fish 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU camp ...
- Cats and Fish HihoCoder - 1631
Cats and Fish HihoCoder - 1631 题意: 有一些猫和一些鱼,每只猫有固定的吃鱼速度,吃的快的猫优先选择吃鱼,问在x秒时有多少完整的鱼和有多少猫正在吃鱼? 题解: 模拟一下. ...
- 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
时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They are all happy ...
- KnockoutJS 3.X API 第四章(14) 绑定语法细节
data-bind绑定语法 Knockout的声明性绑定系统提供了一种简洁而强大的方法来将数据链接到UI. 绑定到简单的数据属性或使用单个绑定通常是容易和明显的. 对于更复杂的绑定,它有助于更好地了解 ...
- 【Knockout】四、绑定上下文
Binding context binding context是一个保存数据的对象,你可以在你的绑定中引用它.当应用绑定的时候,knockout自动创建和管理binding context的继承关系. ...
- KnockoutJS(3)-绑定语法
绑定语法大致分为2种: 1. 数据绑定(data-bind syntax) 2. 绑定上下文(Binding Context) 下面针对这2中绑定语法分别介绍一下 1. 绑定上下文(Binding C ...
随机推荐
- idea快捷键及快捷方法(待完善)
一.快捷键 alt+insert 插入get.set.构造函数等 ctrl+shift+alt+g 生成注释文档 ctrl+shift+alt+z 移除注释文档 Ctrl + Alt ...
- PAT 甲级 1008 Elevator (20)(代码)
1008 Elevator (20)(20 分) The highest building in our city has only one elevator. A request list is m ...
- PAT 1024 科学计数法 (20)(精简版代码+思路+推荐测试样例)
1024 科学计数法 (20)(20 分) 科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式[+-][1-9]"."[0-9]+E[+-][0-9]+, ...
- 探索未知种族之osg类生物---器官初始化三
当判断到viewer中没有一个graphicContext可用时,osg就会默认的进行一次对viewer的实现操作,这样可以保证osg以后可以安心的在屏幕上进行作画.那我们就来看看这个osgViewe ...
- libnet 库使用(一)
该库的相关资料主要从源码包中获得(假设当前路径为源码包路径): ./sample 中有代码示例 ./doc/html 中html文件可以通过浏览器打开,参看函数定义 想要的基本上sample中都 ...
- MySQL中的联结表
使用联结能够实现用一条SELECT语句检索出存储在多个表中的数据.联结是一种机制,用来在一条SELECT语句中关联表,不是物理实体,其在实际的数据库表中并不存在,DBMS会根据需要建立联结,且会在查询 ...
- clean
启动tomcat 报 Could not delete D:/online/.metadata/.plugins/org.eclipse.wst.server.core/tm
- h5解决移动端上滑卡顿问题
select{ -webkit-overflow-scrolling: touch;/*解决移动端滑动卡顿问题*/ -webkit-transform: translateZ(0px);/*开启GPU ...
- 【UI测试】--规范性
- 【Linux】 Ncures库的介绍与安装
Ncures库的介绍 ncurses(new curses)是一套编程库,它提供了一系列的函数以便使用者调用它们去生成基于文本的用户界面. ncurses名字中的n意味着“new”,因为它是curse ...