时间限制:1000ms
单点时限:1000ms
内存限制:256MB

描述

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

(最近刷题又陷入瓶颈,真是啥题都卡

附ac代码:
 1 #include<iostream>
2 #include<string.h>
3 #include<algorithm>
4 #include <cstdio>
5 using namespace std;
6 const int maxn = 5005;
7 int nu[maxn];
8 int cnt[maxn];
9 int b[maxn];
10 int main()
11 {
12 int m,n,x;
13 while(~scanf("%d%d%d",&m,&n,&x))
14 {
15 memset(b,0,sizeof(b));
16 for(int i=0;i<n;++i)
17 scanf("%d",&nu[i]);
18 int len=m;
19 int sum=0;
20 int num=0;
21 for(int i=1;i<=x;++i)
22 {
23 for(int j=0;j<n;++j)
24 {
25 if(b[j]==0) len--; //拿出鱼给猫吃
26 if(i%nu[j]==0)//猫吃完鱼
27 {
28 sum++;
29 b[j]=0;
30 }
31 else //猫正在吃鱼
32 {
33 b[j]=1;
34 }
35 if(len==0) break;
36 }
37 if(len==0) break;
38 }
39 for(int i=0;i<n;++i)
40 if(b[i]==1)
41 num++;
42 printf("%d %d\n",m-num-sum,num);
43 }
44
45 return 0;
46 }

hihocoder 1631的更多相关文章

  1. Cats and Fish HihoCoder - 1631

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

  2. hihocoder#1631 : Cats and Fish

    Description There are many homeless cats in PKU campus. They are all happy because the students in t ...

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

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

  4. hihocoder -1121-二分图的判定

    hihocoder -1121-二分图的判定 1121 : 二分图一•二分图判定 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 大家好,我是小Hi和小Ho的小伙伴Net ...

  5. Hihocoder 太阁最新面经算法竞赛18

    Hihocoder 太阁最新面经算法竞赛18 source: https://hihocoder.com/contest/hihointerview27/problems 题目1 : Big Plus ...

  6. hihoCoder太阁最新面经算法竞赛15

    hihoCoder太阁最新面经算法竞赛15 Link: http://hihocoder.com/contest/hihointerview24 题目1 : Boarding Passes 时间限制: ...

  7. 【hihoCoder 1454】【hiho挑战赛25】【坑】Rikka with Tree II

    http://hihocoder.com/problemset/problem/1454 调了好长时间,谜之WA... 等我以后学好dp再来看为什么吧,先弃坑(╯‵□′)╯︵┻━┻ #include& ...

  8. 【hihocoder#1413】Rikka with String 后缀自动机 + 差分

    搞了一上午+接近一下午这个题,然后被屠了个稀烂,默默仰慕一晚上学会SAM的以及半天4道SAM的hxy大爷. 题目链接:http://hihocoder.com/problemset/problem/1 ...

  9. 【hihoCoder】1148:2月29日

    问题:http://hihocoder.com/problemset/problem/1148 给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期). 思路: 1. 将问题转换成求两个日 ...

随机推荐

  1. js reduce数组转对象

    借鉴:https://juejin.im/post/5cfcaa7ae51d45109b01b161#comment这位大佬的处理方法很妙,但是我一眼看过去没有明白,细细琢磨了下,终于明白了 1 co ...

  2. 01-CentOS 8.1安装 Docker

    官方参考地址:https://docs.docker.com/install/linux/docker-ce/centos/ 里面包含包下载地址:https://download.docker.com ...

  3. 15V转5V转3.3V转3V芯片,DC-DC和LDO

    15V电压是属于一般电压,降压转成5V电压,3.3V电压和3V电压,适用于这个电压的DC-DC很多,LDO也是有可以选择的.LDO芯片如PW6206,PW8600等.DC-DC芯片如:PW2162,P ...

  4. 注解 @AutoConfigureBefore 和 @AutoConfigureAfter 的用途

    注解 @AutoConfigureBefore 和 @AutoConfigureAfter 的用途 介绍: 如果你想将在SpringBoot项目中的配置类进行排序,那么用到spring-boot-au ...

  5. 解决 win10 无法安装VS2019,visual studio installer下载进度始终为0

    解决 win10 无法安装VS2019,visual studio installer下载进度始终为0 目录 解决 win10 无法安装VS2019,visual studio installer下载 ...

  6. Property attribute.

    class property(object): """ Property attribute. fget function to be used for getting ...

  7. 在Centos7上安装Python+Selenium+Chrome+Chromedriver

    1.下载Chrome 上一篇文章已经演示过了Python+Selenium+Firefox+Geckodriver安装步骤并通过自动化脚本打开百度 因此当前只需要安装Chrome和Chromedriv ...

  8. loj 10127最大数

    JSOI 2008 最大数 给定一个正整数数列a1​,a2​,a3​,⋯,an​,每一个数都在0∼p–1 之间.可以对这列数进行两种操作: 添加操作:向序列后添加一个数,序列长度变成 n+1: 询问操 ...

  9. poj 2752Seek the Name, Seek the Fame

    Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536KB   64bit IO Format: %I64d &am ...

  10. 【.NET 与树莓派】i2c(IIC)通信

    i2c(或IIC)协议使用两根线进行通信(不包括电源正负极),它们分别为: 1.SDA:数据线,IIC 协议允许在单根数据线上进行双向通信--这条线既可以发送数据,也可以接收数据. 2.SCL:时钟线 ...