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

  1. 2 1 1
  2. 1
  3. 8 3 5
  4. 1 3 4
  5. 4 5 1
  6. 5 4 3 2 1

Sample Output

  1. 1 0
  2. 0 1
  3. 0 3
  4.  
  5. b记录每个猫的状态,正在吃鱼是1,否则是0
    当当前的时间能被猫的吃鱼时间整除,就表示当前的猫吃完了一条鱼
    num表示吃完的鱼的条数,cnt表示剩的鱼的条数
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int a[];
  5. int b[];
  6. int main(){
  7. int m,n,x;
  8. while(cin>>m>>n>>x){
  9. memset(b,,sizeof(b));
  10. for(int i=;i<=n;i++){
  11. cin>>a[i];
  12. }
  13. sort(a+,a+n+);
  14. int num=,cnt=m;
  15. for(int i=;i<=x;i++){
  16. for(int j=;j<=n;j++){
  17. if(b[j]==){
  18. cnt--;
  19. b[j]=;
  20. }
  21. if(i%a[j]==&&b[j]==){
  22. b[j]=;
  23. num++;
  24. }
  25. if(cnt==)
  26. break;
  27. }
  28. if(cnt==)
  29. break;
  30. }
  31. int ans=;
  32. for(int i=;i<=n;i++){
  33. if(b[i]==)
  34. ans++;
  35. }
  36. cout<<m-num-ans<<' '<<ans<<endl;
  37. }
  38. }

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. 免费证书https://lamp.sh/ssl.html

    https(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的 http 通道,简单讲是 http 的安全版.即 ht ...

  2. dangerouslySetInnerHTMl

    dangerouslySetInnerHTMl 是React标签的一个属性,类似于angular的ng-bind: 听说这个单词这么长,是故意的,应为有可能不合时宜的使用innerHTML会导致XSS ...

  3. DirectX中坐标系问题

    自己属于笨类型,以前总是记不住directx坐标系是怎样的,今天在网上看到一篇文章,借鉴过来. 1. 明确DirectX是左手坐标系. 描述如下:1. 伸出左手,手面朝上,手背朝下,握住z轴,大拇指方 ...

  4. CSS学习总结2:CSS框模型

    1.CSS框模型概述 CSS框模型规定了元素框处理元素内容.内边框.边框和外边框的方式. 元素框的最内部分是实际的内容,直接包围内容的是内边距.内边距呈现了元素的背景.内边距的边缘是边框.边框以外是外 ...

  5. C# 在网页中将Base64编码的字符串显示成图片

    在写一个接口,返回的json里面有图片,是Base64编码的字符串. 测试接口的时候,发现原来在html显示,是直接可以将Base64编码的字符串显示成图片的. 格式如下: <img src=d ...

  6. Android.PackageManager

    1. Apk的安装和更新过程是怎样的呢? Ref[1] 2. 在安装.apk程序包时, .so是如何选择并安装的? 这里的选择是指,是如何根据CPU_ABI和CPU_ABI2的值来选择合适的.so的. ...

  7. [Centos] ERROR: Could not find useradd in chroot, maybe the install failed?

    [mockbuild at localhost ~]$ mock -r centos-5-x86_64-testdev.cfg initinitcleanprepThis may take a whi ...

  8. GET与POST传递数据的长度分析

    在客户机和服务器之间进行请求-响应时,两种最常被用到的方法是:GET 和 POST.GET - 从指定的资源请求数据,POST - 向指定的资源提交要被处理的数据.本篇文章我们就来分析一下GET与PO ...

  9. 标准IO缓冲机制

    参考资料: https://q16964777.iteye.com/blog/2228244 知道缓冲有几种模式:无缓冲.行缓冲.全缓冲.通过判断FILTE中的 _flags 的判断可以知道究竟是那种 ...

  10. Memcache类

    class Memcache{ private static $mem = null; public function mem_create(){ self::$mem = new \Memcache ...