博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
FZU-2219 StarCraft(贪心)
阅读量:5230 次
发布时间:2019-06-14

本文共 2390 字,大约阅读时间需要 7 分钟。

 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
#include
#include
#include
#define INF 0x3f3f3f3fusing 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
pq; node a; cin>>n>>m>>k; for(int i=0;i
>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<
<

  

转载于:https://www.cnblogs.com/luowentao/p/8997053.html

你可能感兴趣的文章
黑马程序员_Java基础枚举类型
查看>>
一位90后程序员的自述:如何从年薪3w到30w!
查看>>
在.net core上使用Entity FramWork(Db first)
查看>>
UIImage 和 iOS 图片压缩UIImage / UIImageVIew
查看>>
MongoDB的数据库、集合的基本操作
查看>>
ajax向后台传递数组
查看>>
疯狂JAVA16课之对象与内存控制
查看>>
[转载]树、森林和二叉树的转换
查看>>
软件测试-----Graph Coverage作业
查看>>
django ORM创建数据库方法
查看>>
创建Oracle synonym 详解
查看>>
php7 新特性整理
查看>>
RabbitMQ、Redis、Memcache、SQLAlchemy
查看>>
linux查看端口占用
查看>>
Sql常见面试题 受用了
查看>>
知识不是来炫耀的,而是来分享的-----现在的人们却…似乎开始变味了…
查看>>
CSS背景颜色、背景图片、平铺、定位、固定
查看>>
口胡:[HNOI2011]数学作业
查看>>
我的第一个python web开发框架(29)——定制ORM(五)
查看>>
中国剩余定理
查看>>