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的更多相关文章

  1. hihoCoder 1631 Cats and Fish(ACM-ICPC北京赛区2017网络同步赛)

    时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They are all happy ...

  2. 2017 ICPC beijing E - Cats and Fish

    #1631 : Cats and Fish 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU camp ...

  3. Cats and Fish HihoCoder - 1631

    Cats and Fish HihoCoder - 1631 题意: 有一些猫和一些鱼,每只猫有固定的吃鱼速度,吃的快的猫优先选择吃鱼,问在x秒时有多少完整的鱼和有多少猫正在吃鱼? 题解: 模拟一下. ...

  4. 2017 北京网络赛 E Cats and Fish

    Cats and Fish 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They ...

  5. Cats and Fish(小猫分鱼吃吱吱吱!)(我觉得是要用贪心的样子!)

    炎炎夏日,一堆

  6. hihocoder 1631

    时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They are all happy ...

  7. KnockoutJS 3.X API 第四章(14) 绑定语法细节

    data-bind绑定语法 Knockout的声明性绑定系统提供了一种简洁而强大的方法来将数据链接到UI. 绑定到简单的数据属性或使用单个绑定通常是容易和明显的. 对于更复杂的绑定,它有助于更好地了解 ...

  8. 【Knockout】四、绑定上下文

    Binding context binding context是一个保存数据的对象,你可以在你的绑定中引用它.当应用绑定的时候,knockout自动创建和管理binding context的继承关系. ...

  9. KnockoutJS(3)-绑定语法

    绑定语法大致分为2种: 1. 数据绑定(data-bind syntax) 2. 绑定上下文(Binding Context) 下面针对这2中绑定语法分别介绍一下 1. 绑定上下文(Binding C ...

随机推荐

  1. HDOJ4734 F(x)

    原题链接 数位\(DP\),继续套记搜模板 定义\(f[pos][now]\),\(pos\)是枚举到的位数,\(now\)是\(A\)的权值减去当前枚举的数的权值,即剩余权值大小. 然后就是记搜模板 ...

  2. UIButton 设置图片文字垂直居中排列

    #pragma mark 按钮图片文字垂直居中排列 -(void)setButtonContentCenter:(UIButton *)button { CGSize imgViewSize,titl ...

  3. Vuebnb 一个用 vue.js + Laravel 构建的全栈应用

    今年我一直在写一本新书叫全栈Vue网站开发:Vue.js,Vuex和Laravel.它会在Packt出版社在2018年初出版. 这本书是围绕着一个案例研究项目,Vuebnb,简单克隆Airbnb.在这 ...

  4. jquery全选反选

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. 查看PHP代码执行的时间

    $t1 = microtime(true); //...要执行的代码$t2 = microtime(true); echo '耗时'.round($t2-$t1,3).'秒';

  6. oralce的lag和lead函数

    https://www.cnblogs.com/always-online/p/5010185.html

  7. js使用sessionStorage、cookie保存token

    本文是参考别人的博客写的,图片直接用的别人的 1.Token:token是客户端频繁向服务器端请求数据,服务器频繁的去数据库查询用户名和密码进行对比,判断用户名和密码正确与否,并作出相应的提示,在这样 ...

  8. spring boot 启动自动跳到 断点 throw new SilentExitException

    项目 debug 启动,自动跳到 断点 ,而且就算F8 ,项目还是停止启动. 百度了一下,答案都是 Eclipse -> Preferences ->Java ->Debug去掉&q ...

  9. cxf 介绍

    CXF 编辑     目录 1Apache CXF 简介 关于Apache CXF 功能特性 项目目标 2Apache CXF特点 灵活部署 支持多种编程语言 代码生成     1Apache CXF ...

  10. git学习笔记:一台电脑上配置两个git账户

    如何在一台电脑上配置两个git账户,现在云端仓库很多,有开源中国的 gitee.com 微软的 github.com 还有 gitlab.com 和 bitbucket.org 等等,下面是具体步骤 ...