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 ...
随机推荐
- BOM浏览器对象模型;
1.window.open(url,ways) url是打开的网页地址 ways是打开方式(-blank:-self) 2.window.close()关闭窗口 3.浏览器的用户信息 window.n ...
- 1S - 平方和与立方和
给定一段连续的整数,求出他们中所有偶数的平方和以及所有奇数的立方和. Input 输入数据包含多组测试实例,每组测试实例包含一行,由两个整数m和n组成. Output 对于每组输入数据,输出一行,应 ...
- nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/support/PersistenceExceptionTranslator
该问题是少了一个spring-tx-的jar包,把该包加入到buildpath中就行了. 参考链接:http://blog.csdn.net/Rongbo_J/article/details/4666 ...
- Luogu 2812 校园网络 - Tarjan
Description 给出一个有向图, 要求出至少从哪几个点出发, 能不漏地经过所有节点. 再求出至少加几条边, 才能使图变成一个强联通分量 Solution 求出所有强联通分量, 形成一个有向无环 ...
- C++/CLI学习入门
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAxIAAAFlCAYAAAB/fN6bAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjw
- jQuery操作(二)
一: 操作元素 1. 属性操作 1.1 $("p").text() $("p").html() $(":checkbox").val() 1 ...
- python range用法
1. range(n) 相当于枚举 从0<=i<n的整数 增量为1 for i in range(4): print(i) 结果:0 1 2 3 2. range(5,10) 相当于枚举 ...
- JVM新生代到老年代基础了解
JVM区域总体分两类,heap区和非heap区. heap区又分为: - Eden Space(伊甸园). - Survivor Space(幸存者区). - Old Gen(老年代). 1个Eden ...
- JAVA钩子方法+模板方法
模板方法: 写一个抽象类,这个抽象类有多个抽象方法,里面设立一个模板方法,这个模板方法也可以称之为模板算法,设立不同方法的执行顺序,封装业务流程,暴露出去: 模板方法模式的特点很好总结,它将一般性的可 ...
- [C#.net]处理UTF-8文件乱码
今天帮同事处理一个2M左右的文件的格式,发现使用Encoding.default & Encoding.UTF8 & Encoding.GetEncoding("GB2312 ...