#1631 : Cats and Fish

时间限制: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
/*
模拟
*/
#include <bits/stdc++.h> #define MAXN 123 using namespace std; struct Node{
int id,val;
Node(){}
Node(int _id,int _val){
id=_id;
val=_val;
}
bool operator < (const Node & other) const {
return val<other.val;
}
};
int m,n,x;
int a[MAXN];
int b[MAXN];
vector<Node>v; inline void init(){
memset(b,,sizeof b);
memset(a,,sizeof a);
v.clear();
} int main(){
// freopen("in.txt","r",stdin);
while(scanf("%d%d%d",&m,&n,&x)!=EOF){
init();
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
for(int i=;i<=x;i++){
int tol=;
for(int j=;j<=n;j++){
if(b[j]==){
tol++;
}
}
if(tol>m){//不够了
if(m>){
v.clear();
for(int j=;j<=n;j++){
if(b[j]==)
v.push_back(Node(j,a[j]));
}
sort(v.begin(),v.end());
for(int j=;j<(int)v.size();j++){
if(m<=)
break;
m--;
b[v[j].id]=a[v[j].id];
}
}
}else{//够
for(int j=;j<=n;j++){//喂鱼
if(b[j]==){
m--;
b[j]=a[j];
}
}
}
for(int j=;j<=n;j++){//吃鱼
b[j]--;
}
}
int res=;
for(int i=;i<=n;i++){
if(b[i]>)
res++;
}
printf("%d %d\n",m,res);
}
return ;
}

2017 ICPC beijing E - Cats and Fish的更多相关文章

  1. 2017 ICPC beijing F - Secret Poems

    #1632 : Secret Poems 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The Yongzheng Emperor (13 December 1678 – ...

  2. 2017 北京网络赛 E Cats and Fish

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

  3. Cats and Fish HihoCoder - 1631

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

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

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

  5. hihocoder#1631 : Cats and Fish

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

  6. 2017 icpc 沈阳网络赛

    cable cable cable Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  7. Cats and Fish(小猫分鱼吃吱吱吱!)(我觉得是要用贪心的样子!)

    炎炎夏日,一堆

  8. 2017 ICPC 广西邀请赛1004 Covering

    Covering Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  9. 2017 ICPC区域赛(西安站)--- J题 LOL(DP)

    题目链接 problem description 5 friends play LOL together . Every one should BAN one character and PICK o ...

随机推荐

  1. 阿里云中linux 下svn服务器安装

    摘要: 安装步骤如下: 1.yum install subversion 2.输入rpm -ql subversion查看安装位置,如下图:   我们知道svn在bin目录下生成了几个二进制文件. 输 ...

  2. mysql5.6 无法远程连接问题解决

    需要配置mysql5.6版本的my.cnf文件,我的my.cnf文件配置如下: port=3306是我后来自己加上的.加上这个之后重启mysql service mysqld restart 记得给r ...

  3. bash脚本练习

    练习一: 1.添加5个用户,user1,...,user5: 2.每个用户的密码同用户名,添加密码完成后,不显示命令的执行结果: 3.每个用户添加完成后,都要显示用户某某已添加成功. useradd ...

  4. jmeter 函数助手

    1.选项,函数助手对话框,打开函数助手 2.使用方法 输入参数,点击生成,可以直接使用(Name of variable in which to store the result (optional) ...

  5. 使用Iview Menu 导航菜单(非 template/render 模式)

    1.首先直接参照官网Demo例子,将代码拷贝进项目中运行, 直接报错: Cannot read property 'mode' of undefined. 然后查看官网介绍,有一行注意文字,好吧. 2 ...

  6. <cassert>

    文件名:  <cassert> (assert.h) 这是一个C语言的诊断库,assert.h文件中定义了一个可作为标准调试工具的宏函数: assert ; 下面介绍这个宏函数:asser ...

  7. Java开发工程师(Web方向) - 03.数据库开发 - 第1章.JDBC

    第1章--JDBC JDBC基础 通过Java Database Connectivity可以实现Java程序对后端数据库的访问 一个完整的数据库部署架构,通常是由客户端和服务器端两部分组成 客户端封 ...

  8. 周期串 (Periodic Strings,UVa455)

    #include<stdio.h> #include<string.h> int main(void) { int n,stlen,i,j; ]; while(scanf(&q ...

  9. Quartz定时器原理与使用

    Quartz是OpenSymphony开源组织在Job scheduling领域又一个开源项目,是一个完全由java编写的开源作业调度框架. Quartz可以用来创建简单或为运行十个,百个,甚至是好几 ...

  10. Redis4.0支持的新功能说明

    本文以华为云DCS for Redis版本为例,介绍Redis4.0的新功能.文章转载自华为云帮助中心. 与Redis3.x版本相比,DCS的Redis4.x以上版本,除了开源Redis增加的特性之外 ...