时间限制: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. Hadoop2.7.7阿里云安装部署

    阿里云的网络环境不需要我们配置,如果是在自己电脑上的虚拟机,虚拟机的安装步骤可以百度.这里是单机版的安装(也有集群模式的介绍)使用Xshell连接阿里云主机,用命令将自己下载好的安装包上传到服务器 # ...

  2. 干电池升压IC

    1, 干电池升压IC                         升压输出3V,3,3V,5V等3V-5V可调   2, 单节锂电池升压IC                     升压输出4.2 ...

  3. Spring基于注解开发的注解使用之AOP(部分源代码分析)

    AOP底层实现动态代理 1.导入spring-aop包依赖 <!--aopV1--> <dependency> <groupId>org.springframewo ...

  4. physical CPU vs logical CPU vs Core vs Thread vs Socket(翻译)

    原文地址: http://www.daniloaz.com/en/differences-between-physical-cpu-vs-logical-cpu-vs-core-vs-thread-v ...

  5. 【网络安全】IOC概念浅析

    OpenIOC(Open Indicator of Compromise,开放威胁指标) MANDIANT 公司发布的情报共享规范,是开源.灵活的框架.OpenIOC是一个记录.定义以及共享威胁情报的 ...

  6. P2573 [SCOI2012]滑雪 题解

    下午花了三个小时肝这道题,心态差点爆炸! 下面是分析: 1 题目要求: 2 求最小生成树 3 但是 4 - a是从1号点开始的 --> 如果以后的某个点比一号高,则不可能到达 5 - a只能从高 ...

  7. (八)整合 Dubbo框架 ,实现RPC服务远程调用

    整合 Dubbo框架 ,实现RPC服务远程调用 1.Dubbo框架简介 1.1 框架依赖 1.2 核心角色说明 2.SpringBoot整合Dubbo 2.1 核心依赖 2.2 项目结构说明 2.3 ...

  8. Excel三个下拉互斥

    Excel三个下拉互斥 描述:Excel有三个下拉列表,若选择了其中任意一个下拉,其他两个均不可以在选择. 尝试了很多种办法,级联,数据有效性等等,最后都没实现. 老大,最后用VBA实现. 附上代码: ...

  9. Django(自定义过滤器和自定义标签)

    模版是一个用django模版语言标记过的python字符串.模版可以包含模版标签和变量. 模版标签是在一个模版里起作用的标记.比如,一个模版标签可以产生控制结构的内容(if或者for),可以获取数据库 ...

  10. WLAN参数释义及优化建议

    1.AP覆盖范围或天线角度 1)参数释义 AP覆盖范围或天线角度直接影响到了终端连接到WLAN的信号强度. 2)优化建议 在设备的工程安装过程中,合理选择AP的位置,合理调整AP的覆盖方向或外置天线的 ...