2017 北京网络赛 E Cats and Fish
描述
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
题意:n条鱼,m只猫,x是时间,给定每一只猫吃鱼的速度,问x时间之后,还剩多少条鱼,又有多少条鱼正在被吃
模拟即可
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<string>
#include<string.h>
#include<vector>
#include<utility>
#include<map>
#include<queue>
#include<set>
#define mx 0x3f3f3f3f
#define ll long long
using namespace std;
int n,m,x;
int a[],vis[];
priority_queue<int,vector<int>,greater<int> >p;
int main()
{
while(~scanf("%d%d%d",&m,&n,&x))
{
memset(vis,,sizeof(vis));
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
sort(a+,a+n+);
int now=;
for(int i=;i<=x;i++)
{
for(int j=;j<=n;j++)
{
if(m==)
break;
if(i%a[j]==)
{
if(a[j]==)
m--;
if(vis[j]==)
{
vis[j]=;
now--;
}
}
else
{
if(vis[j]==)
{
now++;
m--;
vis[j]=;
} }
if(m==&&now==)
break;
}
if(m==&&now==)
break;
}
printf("%d %d\n",m,now);
}
return ;
}
2017 北京网络赛 E Cats and Fish的更多相关文章
- 2017北京网络赛 Bounce GCD加找规律
题目链接:http://hihocoder.com/problemset/problem/1584 题意:就是求一个小球从矩阵的左上角,跑到矩形的右下角不能重复经过的格子,小球碰到墙壁就反射. 解法: ...
- hihocode 1584 : Bounce (找规律)(2017 北京网络赛G)
题目链接 比赛时随便找了个规律,然后队友过了.不过那个规律具体细节还挺烦的.刚刚偶然看到Q巨在群里提到的他的一个思路,妙啊,很好理解,而且公式写起来也容易.OrzQ巨 #include<bits ...
- hihocoder 1582 : Territorial Dispute (计算几何)(2017 北京网络赛E)
题目链接 题意:给出n个点.用两种颜色来给每个点染色.问能否存在一种染色方式,使不同颜色的点不能被划分到一条直线的两侧. 题解:求个凸包(其实只考虑四个点就行.但因为有板子,所以感觉这样写更休闲一些. ...
- 2017北京网络赛 J Pangu and Stones 区间DP(石子归并)
#1636 : Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the fi ...
- 2017北京网络赛 F Secret Poems 蛇形回路输出
#1632 : Secret Poems 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The Yongzheng Emperor (13 December 1678 – ...
- hihocoder1236(北京网络赛J):scores 分块+bitset
北京网络赛的题- -.当时没思路,听大神们说是分块+bitset,想了一下发现确实可做,就试了一下,T了好多次终于过了 题意: 初始有n个人,每个人有五种能力值,现在有q个查询,每次查询给五个数代表查 ...
- 2015北京网络赛 D-The Celebration of Rabbits 动归+FWT
2015北京网络赛 D-The Celebration of Rabbits 题意: 给定四个正整数n, m, L, R (1≤n,m,L,R≤1000). 设a为一个长度为2n+1的序列. 设f(x ...
- 2015北京网络赛 J Scores bitset+分块
2015北京网络赛 J Scores 题意:50000组5维数据,50000个询问,问有多少组每一维都不大于询问的数据 思路:赛时没有思路,后来看解题报告也因为智商太低看了半天看不懂.bitset之前 ...
- 2015北京网络赛 Couple Trees 倍增算法
2015北京网络赛 Couple Trees 题意:两棵树,求不同树上两个节点的最近公共祖先 思路:比赛时看过的队伍不是很多,没有仔细想.今天补题才发现有个 倍增算法,自己竟然不知道. 解法来自 q ...
随机推荐
- kudu-master服务启动失败
执行service kudu-master start , 提示启动失败failed. 进入报错日志目录 (cd /var/log/kudu/),看到报错信息(vim kudu-master.ER ...
- Python 之并发编程之线程上
一.线程概念 进程是资源分配的最小单位 线程是计算机中调度的最小单位 多线程(即多个控制线程)的概念是,在一个进程中存在多个控制线程,多个控制线程共享该进程的地址空间,相当于一个车间内有多条流水线,都 ...
- 在spring boot中使用jasypt对配置文件中的敏感字符串加密
在spring boot的配置文件application.property(application.yml)文件中常常配置一些密码类的字符,如果用明文则很容易被盗用,可以使用jasypt在配置密码的地 ...
- 【原】Linux中常见服务介绍
1.SSH介绍 简单说,SSH(Secure Shell Protocol)是一种网络协议,用于计算机之间的加密登录.在默认状态下SSH服务提供俩个服务功能,一个是提供类似telnet远程联机服务器的 ...
- c++刷算法的好处
写再最前面:摘录于柳神的笔记 在已经学习过C语⾔的前提下,学习C++并使⽤它刷算法的学习成本⾮常低-只需要⼏个⼩时就可 以学会- C++向下兼容C,C语⾔⾥⾯的语法完全可以在C++⽂件中运⾏,所以学习 ...
- SWD学习笔记
SWD其实和JTAG类似,是一种调试串口. JTAG大致了解了一下.JTAG(Joint Test Action Group)主要4 lines:TMS(模式选择),TCK(时钟),TDI(数据输入) ...
- linux搭建mysql时ifconfig命令无法使用问题
刚搭建好的Centos 最小安装模式是没有ifconfig命令的.改变步骤:一:使用语句:cd /etc/sysconfig/network-scripts/二:使用语句vi ifcfg-eno167 ...
- Derivative Pricing_1_Black
1. Stock Option wih divends 1.1 Task A 1.1.1 Calculate a ECO on a stock. /Ex-dividend dates in 3 and ...
- Flask - 数据库相关
1. Flask-SQLAlchemy 1.1 参考: http://flask-sqlalchemy.pocoo.org/2.3/ https://github.com/janetat/flasky ...
- ws2_32.dll的妙用与删除 (禁网)
ws2_32.dll是Windows Sockets应用程序接口,用于支持Internet和网络应用程序.程序运行时会自动调用ws2_32.dll文件,ws2_32.dll是个动态链接库文件位于系统文 ...