hihocoder 1631
描述
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的更多相关文章
- Cats and Fish HihoCoder - 1631
Cats and Fish HihoCoder - 1631 题意: 有一些猫和一些鱼,每只猫有固定的吃鱼速度,吃的快的猫优先选择吃鱼,问在x秒时有多少完整的鱼和有多少猫正在吃鱼? 题解: 模拟一下. ...
- hihocoder#1631 : Cats and Fish
Description There are many homeless cats in PKU campus. They are all happy because the students in t ...
- hihoCoder 1631 Cats and Fish(ACM-ICPC北京赛区2017网络同步赛)
时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They are all happy ...
- hihocoder -1121-二分图的判定
hihocoder -1121-二分图的判定 1121 : 二分图一•二分图判定 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 大家好,我是小Hi和小Ho的小伙伴Net ...
- Hihocoder 太阁最新面经算法竞赛18
Hihocoder 太阁最新面经算法竞赛18 source: https://hihocoder.com/contest/hihointerview27/problems 题目1 : Big Plus ...
- hihoCoder太阁最新面经算法竞赛15
hihoCoder太阁最新面经算法竞赛15 Link: http://hihocoder.com/contest/hihointerview24 题目1 : Boarding Passes 时间限制: ...
- 【hihoCoder 1454】【hiho挑战赛25】【坑】Rikka with Tree II
http://hihocoder.com/problemset/problem/1454 调了好长时间,谜之WA... 等我以后学好dp再来看为什么吧,先弃坑(╯‵□′)╯︵┻━┻ #include& ...
- 【hihocoder#1413】Rikka with String 后缀自动机 + 差分
搞了一上午+接近一下午这个题,然后被屠了个稀烂,默默仰慕一晚上学会SAM的以及半天4道SAM的hxy大爷. 题目链接:http://hihocoder.com/problemset/problem/1 ...
- 【hihoCoder】1148:2月29日
问题:http://hihocoder.com/problemset/problem/1148 给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期). 思路: 1. 将问题转换成求两个日 ...
随机推荐
- Java入门者:如何写出美观的Java代码?
前言 在帮助各位同学远程解决代码问题的时候,发现很多同学的代码都有一个共同问题:代码书写格式不规范.虽然代码书写规范对程序性能及运行并不影响,但影响着别人对你编程习惯或能力的第一印象,同时也会给阅读者 ...
- linux下删除文件夹及下面所有文件
使用rm -rf 目录名字 命令即可 -r 就是向下递归,不管有多少级目录,一并删除-f 就是直接强行删除,不作任何提示的意思 rm 不带参数 只能删除文件 rm test.txt mkdir /us ...
- 集成多种协议、用于 USBC 端口的快充协议芯片IP2723
1. 特性 快充规格 集成 QC4/QC4+输出快充协议 - 兼容 QC2.0/QC3.0 - 支持 Class B 电压等级 集成 FCP 输出快充协议 集成 SCP 输出快充协议 集成 ...
- 【Android】编译报错 Annotation processors must be explicitly declared now 解决方案
问题 在网上下载一个demo,因为版本久远,里面添加了本地 Butter Knife 的jar包,在编译时报错 Annotation processors must be explicitly dec ...
- 部署自动初始化Schema的数据库
我们使用容器的方式部署数据库组件,特别是企业有大量的项目开发业务的,部署的开发.测试数据库组件较多时.经常会遇到以下问题: 业务需要使用数据库,但部署完数据库后,需要在数据库中执行创建schema的操 ...
- synchronized的jvm源码分析聊锁的意义
上篇写完了ReentrantLock源码实现,从我们的角度分析设计锁,在对比大神的实现,顺道拍了一波道哥的马屁,虽然他看不到,哈哈.这一篇我们来聊一聊synchronized的源码实现,并对比reen ...
- Fastjson1.2.24反序列化漏洞复现
Fastjson1.2.24 目录 1. 环境简介 1.1 物理环境 1.2 网络环境 1.3 工具 1.4 流程 2. Docker+vulhub+fastjson1.2.24 2.1 Docker ...
- 文件的上传/下载+在线游览(转化html)--不需要在线插件//自己写的小方法
1 /// <summary> 2 /// 文件上传下载帮助类 3 /// </summary> 4 public static class FileHelper 5 { 6 ...
- URL 重定向机制
由于存在上述三种 URL 重定向机制,那么在多种方法同时设定的情况下,哪种方法会首先起作用呢?优先级顺序如下: HTTP 协议的重定向机制永远最先触发,即便是在没有传送任何页面--也就没有页面被(客户 ...
- Codeforces #698 (Div. 2) E. Nezzar and Binary String 题解
中文题意: 给你两个长度为 \(n\) 的01串 \(s,f,\)有 \(q\) 次询问. 每次询问有区间 \([\ l,r\ ]\) ,如果 \([\ l,r\ ]\) 同时包含\(0\)和\(1\ ...