Problem 2219 StarCraft

Accept: 294    Submit: 860
Time Limit: 1000 mSec    Memory Limit : 32768 KB

 Problem Description

ZB loves playing StarCraft and he likes Zerg most!

One day, when ZB was playing SC2, he came up with an idea:

He wants to change the queen's ability, the queen's new ability is to choose a worker at any time, and turn it into an egg, after K units of time, two workers will born from that egg. The ability is not consumed, which means you can use it any time without cooling down.

Now ZB wants to build N buildings, he has M workers initially, the i-th building costs t[i] units of time, and a worker will die after he builds a building. Now ZB wants to know the minimum time to build all N buildings.

 Input

The first line contains an integer T, meaning the number of the cases. 1 <= T <= 50.

For each test case, the first line consists of three integers N, M and K. (1 <= N, M <= 100000, 1 <= K <= 100000).

The second line contains N integers t[1] ... t[N](1 <= t[i] <= 100000).

 Output

For each test case, output the answer of the question.

 Sample Input

2
3 1 1
1 3 5
5 2 2
1 1 1 1 10

 Sample Output

6
10

 Hint

For the first example, turn the first worker into an egg at time 0, at time 1 there’s two worker. And use one of them to build the third building, turn the other one into an egg, at time 2, you have 2 workers and a worker building the third building. Use two workers build the first and the second building, they are built at time 3, 5, 6 respectively.

 Source

第六届福建省大学生程序设计竞赛-重现赛(感谢承办方华侨大学)

题意:起始有m个农民,要建N个建筑,建第i个建筑要用t[i]个时间,不过可以指定一个农民变成蛋在K时间后变成两个农民,每次农民只能建立一个建筑
思路:每次把需要消耗最少时间建筑的农民分裂,保证时间最充分利用
代码“

#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
struct node{
int time;
bool operator <(const node &a)const{
return time>a.time;
}
}; int main(){
int t;
std::ios::sync_with_stdio(false);
cin>>t;
while(t--){
int n,m,k;
priority_queue<node>pq;
node a;
cin>>n>>m>>k;
for(int i=0;i<n;i++){
cin>>a.time;
pq.push(a);
}
while(n>m){
pq.pop();
node a=pq.top();
a.time+=k;
pq.push(a);
pq.pop();
n--;
}
while(pq.size()!=1)pq.pop();
cout<<pq.top().time<<endl;
}
return 0;
}

  

FZU-2219 StarCraft(贪心)的更多相关文章

  1. FZU 2219 StarCraft(星际争霸)

    Description 题目描述 ZB loves playing StarCraft and he likes Zerg most! One day, when ZB was playing SC2 ...

  2. FZU 2219【贪心】

    思路: 因为工人造完一个房子就死了,所以如果m<n则还需要n-m个工人. 最优的方案应该是耗时长的房子应该尽快建,而且最优的是越多的房子在建越好,也就是如果当前人数不到n,只派一个人去分裂. 解 ...

  3. FZOJ Problem 2219 StarCraft

                                                                                                        ...

  4. FZU 2102 Solve equation(水,进制转化)&& FZU 2111(贪心,交换使数字最小)

    C Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Pra ...

  5. FZU 2233 ~APTX4869 贪心+并查集

    分析:http://blog.csdn.net/chenzhenyu123456/article/details/51308460 #include <cstdio> #include & ...

  6. FZU 2139——久违的月赛之二——————【贪心】

    久违的月赛之二 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  7. 贪心 FZU 2013 A short problem

    题目传送门 /* 题意:取长度不小于m的序列使得和最大 贪心:先来一个前缀和,只要长度不小于m,从m开始,更新起点k最小值和ans最大值 */ #include <cstdio> #inc ...

  8. FZU Problem 2221 RunningMan(贪心)

    一开始就跑偏了,耽误了很长时间,我和队友都想到博弈上去了...我严重怀疑自己被前几个博弈题给洗脑了...贪心的做法其实就是我们分两种情况,因为A先出,所以B在第一组可以选择是赢或输,如果要输,那直接不 ...

  9. FZU 2144 Shooting Game(数学+贪心)

    主要思路:求出蚊子到达球的时间区间(用方程得解),对区间做一个贪心的选择,选择尽可能多的区间有交集的区间段(结构体排序即可),然后计数. #include <cstdio> #includ ...

随机推荐

  1. Python import与from import使用

    Python程序可以调用一组基本的函数(即内建函数),比如print().input()和len()等函数.Python本身也内置一组模块(即标准库).每个模块都是一个Python程序,且包含了一组相 ...

  2. 关于windows10设置环境变量的问题

    在设置环境变量的时候往往在网上能找到这样的文章: 1:新建环境变量 2:将新增的环境变量 加到path 变量中: 3.由于有的小伙伴的 系统是 windows10 在点击 编辑path 环境变量的时候 ...

  3. jmeter察看结果树响应数据中文乱码解决办法

    1.到jmeter目录文件中bin文件夹下找到jmeter.properties文件,该文件为jmeter配置文件.使用编辑工具打开它. 2.找到    #sampleresult.default.e ...

  4. 如何在乌班图上配置java开发环境

    不想说的那么细,每条命令都说一下,在现在这个浮躁的时代,很少有人能看的下去,我就直接上命令,最简单的快捷的方式. 1:安装软件 2:设置root密码 3:配置mysql远程登录 4:安装java运行环 ...

  5. Python——开篇之词

    我也断断续续的用Python挺长时间了.但是一直都没有系统的学习过Python.很多东西都是现用现学.这样感觉对Python的理解太浅,完完全全就是搬砖的. 因此,我专门找了一个比较完整的老男孩的Py ...

  6. CentOS6.5下搭建LAMP环境(源码编译方式)

    CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL) 学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP ,WAMP,MAMP等.这里我介 ...

  7. 云效(阿里云)流水线 + nginx + uWsgi + flask + python3 基础环境搭建 --备忘

    一.开发环境搭建 1.安装python3 yum -y groupinstall "Development tools" yum -y install zlib-devel bzi ...

  8. C++寒假学习计划

    课程 中国大学mooc西北工业大学c++程序设计 理由 本课程有48节,章节分类清晰,由许多小知识块组成,条例清晰便于学习,由基础开始,由浅入深,适合我这种小白. 计划 从2.8号至2.28除去2.1 ...

  9. 201621123034 《Java程序设计》第8周学习总结

    作业08-集合 1. 本周学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 2. 书面作业 1. ArrayList代码分析 1.1 解释ArrayList的contains源代码 答 ...

  10. ocrosoft Contest1316 - 信奥编程之路~~~~~第三关 问题 K: 大整数加法

    http://acm.ocrosoft.com/problem.php?cid=1316&pid=10 题目描述 求两个不超过200位的非负整数的和.   输入 有两行,每行是一个不超过200 ...