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 ...
随机推荐
- 通过aptitude降级包解决依赖问题(E:无法修正错误,因为您要求某些软件包保持现状)
Linux下的依赖关系令人头疼,尤其是提示如下错误的时候: 下列软件包有未满足的依赖关系: xxx : 依赖: xxx 但是它将不会被安装 E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破 ...
- 通过UA实现手机端电脑端的分离!(重点)
实现Nginx区分PC和手机访问不同的网站是物理上完全隔离的两套网站(一套手机端.一套pc端) 这样带来的好处pc端和移动端的内容可以不一样,移动版网站不需要包含特别多内容.只要包含必要的文字和较小的 ...
- subprocess.Popen()
def run(): str_shell='ipconfig' sub=subprocess.Popen(args=str_shell,shell=True,stdin=subprocess.PIPE ...
- jquery怎么获取当前标签下的子标签
1.var num1=$("ul > a:eq(0)").attr("ID");2.var num2=$("ul").children ...
- vue学习笔记:Hello Vue
编写简单例子,了解下基本语法 <!DOCTYPE html> <html> <head> <meta charset="utf-8 "&g ...
- PAT T1008 Airline Routes
用tarjan算法缩点~ #include<bits/stdc++.h> using namespace std; ; vector<int> g[maxn]; int N,M ...
- Maven打包项目失败;报错:Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project Hello: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/we
报错信息: E:\MIKEY\mikey\HTML5\TestMaven_01>mvn package [INFO] Scanning for projects... [INFO] [INFO] ...
- Struts2学习(六)
拦截器原理 1.如图所示,Struts2拦截器的实现原理相对简单,当请求struts2的action时,Struts 2会查找配置文件,并根据其配置实例化相对的拦截器对象,然后串成一个列表,最后一个一 ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 排版:设置浮动和偏移
<!DOCTYPE html> <html> <head> <title>菜鸟教程(runoob.com)</title> <meta ...
- Linux引导过程!(重点)
1.开机自检:服务器开机后,将根据主板BIOS (基本输入系统),中的设置对CPU .内存.显卡.键盘等设备进行初步检测,并初始化部分硬件. 2.MBR 引导:当从本机硬盘中启动系统时,首先根据硬盘中 ...