#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. 如何理解 UL94HB , UL94-V0 , UL94-V1 , UL94-V2

    塑料阻燃等级由HB,V-2,V-1向V-0逐级递增: UL94V0,V1,V2是不同的阻燃等级,其等级不同,耐燃的测试方法亦不同,测试判定的标准也不同. V0的测试方法是将测试物倾斜45度,用酒精灯点 ...

  2. windown reids

    记录Windown安装Redis和php_redis扩展 和Linux系统不同windown中不需要编译安装:只需要下对版本拖拽过去即可: 首先安装redis服务: 可以百度下一个,只要注意系统版本即 ...

  3. 一次IPC无法创建的问题

    背景说明:         后台子系统都是运行在pc上的linux         系统有多个子系统,有一个子系统负责统一启停其他子系统,这里把这个子系统称为olddriver.         ol ...

  4. linux部署MantisBT(三)部署MantisBT

    三.部署MantisBT 1.下载MantisBT https://www.mantisbt.org/download.php 2.将MantisBT安装包放在/apache/htdocs下并重命名为 ...

  5. 《Effective C++》读书笔记 资源管理

    C++程序中最常用的资源包括动态分配的内存,文件描述器,互斥锁,数据库连接,网络socket等等.不论哪种资源,重要的是,当你不再使用他时,必须将他归还给系统. 一个很好的做法是以对象管理资源.把资源 ...

  6. Pandas基础教程

    pandas教程 更多地可以 参考教程 安装 pip install pandas pandas的类excel操作,超级方便: import pandas as pd dates = pd.date_ ...

  7. 贪心算法——Huffman 压缩编码的实现

    1. 如何理解 "贪心算法" 假设我们有一个可以容纳 100 Kg 物品的背包,可以装各种物品.我们有以下 5 种豆子,每种豆子的总量和总价值都各不相同.怎样装才能让背包里豆子的总 ...

  8. 硬件PCB Layout布局布线Checklist检查表(通用版)

    按部位分类 技术规范内容 1 PCB布线与布局 PCB布线与布局隔离准则:强弱电流隔离.大小电压隔离,高低频率隔离.输入输出隔离.数字模拟隔离.输入输出隔离,分界标准为相差一个数量级.隔离方法包括:空 ...

  9. Python中__name__属性的妙用

    在Python中,每一个module文件都有一个built-in属性:__name__,这个__name__有如下特点: 1 如果这个module文件是被别的文件导入的,那么,该__name__属性的 ...

  10. 自测之Lesson10:管道

    题目:建立双向管道,实现:父进程向子进程传送一个字符串,子进程对该字符串进行处理(小写字母转为大写字母)后再传回父进程. 实现代码: #include <stdio.h> #include ...