/**
题目:hdu6000 Wash 巧妙地贪心
链接:https://vjudge.net/contest/173364#problem/B
转自:http://blog.csdn.net/overload1997/article/details/54730156
题意:L件衣服,N个洗衣机,M个烘干机,给出每个洗衣机洗一件衣服的时间和烘干机烘干一件衣服的时间,问需要的最少时间是多少。
思路:这是ccpcfinal的题目,明显是贪心但是很难想出来,首先洗衣服所需的最短时间应该很容易想出来了,
用优先队列弹出下一次先洗完的时间就好了,问题在于烘干,正解应该是倒过来想,
假设全部洗完洪完所需的最小时间是x,那么在x时刻,烘干机全部都已经工作完毕了,
即烘干机全部空闲,那么我们把时间倒过来看,烘干过程等于洗衣服过程,用同样的方法算出最快烘干时间,
然后要最快的时间故肯定是小的+大的,最后取最大值就是我们想要的x了,思路有点复杂,很难说清楚,还是上代码吧。 转自:http://blog.csdn.net/overload1997/article/details/54730156
*/
#include<cstdio>
#include<iostream>
#include<vector>
#include<cstring>
#include<assert.h>
#include<algorithm>
#include<cmath>
#include<queue>
#define P pair<int,int>
using namespace std;
typedef long long LL;
const int maxn = 1e6+;
LL time[maxn];
struct node
{
LL a, b;
node(){}
node(LL a,LL b):a(a),b(b){}
bool operator < (const node&k)const{
return a+b>(k.a+k.b);
}
}top;
int main()
{
int T, L, n, m, cas=;
cin>>T;
while(T--)
{
scanf("%d%d%d",&L,&n,&m);
priority_queue<node> q;
LL t;
for(int i = ; i <= n; i++){
scanf("%lld",&t);
q.push(node(,t));
}
for(int i = ; i <= L; i++){
top = q.top();
q.pop();
time[i] = top.a+top.b;
top.a+=top.b;
q.push(top);
}
while(!q.empty()) q.pop();
for(int i = ; i <= m; i++){
scanf("%lld",&t);
q.push(node(,t));
}
LL ans = ;
for(int i = ; i <= L; i++){
top = q.top(); q.pop();
ans = max(ans,top.a+top.b+time[L-i+]);
top.a += top.b;
q.push(top);
}
printf("Case #%d: %lld\n",cas++,ans);
}
return ;
}

最新文章

  1. 【WCF】如何将WCF部署到远程服务器
  2. java分享第十七天-03(封装操作mysql类)
  3. Xcode插件描述
  4. xml存储bug
  5. SQL Server安全(4/11):许可(Permissions)
  6. POJ 1503
  7. iOS边练边学--cocoaPods管理第三方框架--命令行方式实现
  8. HDU 1404 (博弈) Digital Deletions
  9. ping时不知道ping那个Ip的解决办法
  10. ORACLE函数之日期时间运算函数
  11. 网际协议:无连接数据报交付(IPv4)
  12. REST(Representational State Transfer表述性状态转移)
  13. 数据库原理剖析 - 序列1 - B+树
  14. TFS2015创建项目
  15. python学习笔记1-python相关应用套件
  16. 2PC(Two Phase Commitment Protocol)原理
  17. MongoDB中的读写锁
  18. Unity2018.3全新Prefab预制件系统深入介绍视频教程+PPT+Demo源码
  19. LuoGu P2783 有机化学之神偶尔会做作弊
  20. python3 练习题(购物车)

热门文章

  1. 往aws中的s3上传数据
  2. 解决:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile
  3. android开发笔记之Volley (1)
  4. 绿化和卸载 DOS 批处理
  5. socket何时处于”读就绪状态“?---通过“应用程序大爷&amp;quot;和&amp;quot;内核孙子&amp;quot;对话再看重要的select函数的使用方法
  6. redis学习笔记——RDB和AOF持久化二
  7. 我为什么选择ANGULAR 2?
  8. python中的socket服务器(多线程)
  9. python ---用户输入
  10. andorid手机电脑操作