题意:已知有L件衣服,M个洗衣机,N个烘干机,已知每个机器的工作时间,且每个机器只能同时处理一件衣服,问洗烘完所有衣服所需的最短时间。

分析:

1、优先队列处理出每件衣服最早的洗完时间。

2、优先队列处理出每件衣服最早的烘完时间。

3、用最大的洗完时间与最小的烘完时间相加,取最大值。

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<cstdlib>
  4. #include<cctype>
  5. #include<cmath>
  6. #include<iostream>
  7. #include<sstream>
  8. #include<iterator>
  9. #include<algorithm>
  10. #include<string>
  11. #include<vector>
  12. #include<set>
  13. #include<map>
  14. #include<stack>
  15. #include<deque>
  16. #include<queue>
  17. #include<list>
  18. #define Min(a, b) ((a < b) ? a : b)
  19. #define Max(a, b) ((a < b) ? b : a)
  20. const double eps = 1e-8;
  21. inline int dcmp(double a, double b){
  22. if(fabs(a - b) < eps) return 0;
  23. return a > b ? 1 : -1;
  24. }
  25. typedef long long LL;
  26. typedef unsigned long long ULL;
  27. const int INT_INF = 0x3f3f3f3f;
  28. const int INT_M_INF = 0x7f7f7f7f;
  29. const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
  30. const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
  31. const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
  32. const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
  33. const int MOD = 1e9 + 7;
  34. const double pi = acos(-1.0);
  35. const int MAXN = 1000000 + 10;
  36. const int MAXT = 10000 + 10;
  37. using namespace std;
  38. struct Node{
  39. LL len, et;
  40. Node(LL l, LL t):len(l), et(t){}
  41. bool operator < (const Node& rhs)const{
  42. return et > rhs.et;
  43. }
  44. };
  45. LL washet[MAXN];
  46. priority_queue<Node> q;
  47. int main(){
  48. int T;
  49. scanf("%d", &T);
  50. int kase = 0;
  51. while(T--){
  52. while(!q.empty()) q.pop();
  53. int L, N, M;
  54. scanf("%d%d%d", &L, &N, &M);
  55. LL x;
  56. for(int i = 0; i < N; ++i){
  57. scanf("%lld", &x);
  58. q.push(Node(x, x));
  59. }
  60. for(int i = 0; i < L; ++i){
  61. Node top = q.top();
  62. q.pop();
  63. washet[i] = top.et;
  64. q.push(Node(top.len, top.et + top.len));
  65. }
  66. while(!q.empty()) q.pop();
  67. for(int i = 0; i < M; ++i){
  68. scanf("%lld", &x);
  69. q.push(Node(x, x));
  70. }
  71. LL ans = 0;
  72. for(int i = L - 1; i >= 0; --i){
  73. Node top = q.top();
  74. q.pop();
  75. ans = max(ans, washet[i] + top.et);
  76. q.push(Node(top.len, top.et + top.len));
  77. }
  78. printf("Case #%d: %lld\n", ++kase, ans);
  79. }
  80. return 0;
  81. }

HDU - 6000 Wash(优先队列+贪心)的更多相关文章

  1. HDU 6000 - Wash

    /* HDU 6000 - Wash [ 贪心 ] 题意: L 件衣服,N 个洗衣机,M 个烘干机,给出每个洗衣机洗一件衣服的时间和烘干机烘干一件衣服的时间,问需要的最少时间是多少 分析: 先求出L件 ...

  2. hdu 5360 Hiking(优先队列+贪心)

    题目:http://acm.hdu.edu.cn/showproblem.php? pid=5360 题意:beta有n个朋友,beta要邀请他的朋友go hiking,已知每一个朋友的理想人数[L, ...

  3. HDU 5289 Assignment [优先队列 贪心]

    HDU 5289 - Assignment http://acm.hdu.edu.cn/showproblem.php?pid=5289 Tom owns a company and he is th ...

  4. HDU 5360 【优先队列+贪心】

    题意: 给定N个无序区间. 对合法区间的定义是: 在这个区间之前已经选出了至少l个合法区间,最多选出了r个合法区间.则该区间为合法区间. 输出最多能挑选出多少个合法区间,并输出合法区间的数量. 思路: ...

  5. HDU 4442 Physical Examination(贪心)

    HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Descripti ...

  6. 最高的奖励 - 优先队列&贪心 / 并查集

    题目地址:http://www.51cpc.com/web/problem.php?id=1587 Summarize: 优先队列&贪心: 1. 按价值最高排序,价值相同则按完成时间越晚为先: ...

  7. POJ2431 优先队列+贪心 - biaobiao88

    以下代码可对结构体数组中的元素进行排序,也差不多算是一个小小的模板了吧 #include<iostream> #include<algorithm> using namespa ...

  8. hdu3438 Buy and Resell(优先队列+贪心)

    Buy and Resell Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  9. 【HDU 6000】Wash(贪心)

    Problem Description Mr.Panda is about to engage in his favourite activity doing laundry! He's brough ...

随机推荐

  1. android下创建文件夹和修改其权限的方法

    原文:http://www.cnblogs.com/wanqieddy/archive/2011/12/28/2304906.html 由于工作的需要,今天研究了在android下创建文件夹和修改其权 ...

  2. rem与部分手机 字体偏大问题

    原因是部分手机自己设置了巨无霸字体.

  3. QT5静态编译工程(arm交叉编译)

    1.首先,QT编译环境默认是动态库,要编译静态程序是不可能的,所以要下载QT源码,重新编译QT编译环境 2.下载QT源码(5.13版本):http://download.qt.io/developme ...

  4. html常用整理

    视频链接:https://www.bilibili.com/video/av5862916?from=search&seid=12139895566389560177 我的第一个html &l ...

  5. 「国家集训队」Crash的数字表格

    题目描述 求(对 \(20101009\) 取模,\(n,m\le10^7\) ) \[\sum_{i=1}^n\sum_{j=1}^m\operatorname{lcm}(i,j)\] 大体思路 推 ...

  6. php后门拿下当前目录

    Weevely是一个模拟类似telnet的连接的隐形PHP网页shell.它是Web应用程序后期开发的必备工具,可以作为隐形后门程序,也可以作为一个web外壳来管理合法的Web帐户,甚至可以免费托管. ...

  7. CF 1278C Berry Jam 题解

    Forewords 说实话我是被图吸引进来的23333,图画的真的挺好看. 题意 你从一个梯子下到地下室,梯子左右两边各有 \(n\) 瓶果酱排成一排,果酱口味为草莓味或蓝莓味,你每次只能吃你左边或右 ...

  8. Vue Element-Ui 改变el-Input背景样式

    Element-ui是一个非常好的UI设计模块,它提供给我们很多好看的按钮样式,非常适用于快速搭建UI,下面说说如果使用了element-ui之后,要更改它默认的el-Input样式应该怎么操作. 使 ...

  9. Intellij Idea webstorm 激活

    参考: 最新破解 https://www.cnblogs.com/litterCoder/p/12175461.html 推荐 https://mp.weixin.qq.com/s/zxfDAlN8G ...

  10. 图解Mybatis框架原理及使用

    1.前言 努力学习完ssm框架之后,终于也成功的把三大框架的使用以及配置文件细节忘得一干二净.为了努力捡起来以及方便今后的复习,决定写一篇博客记录一下. 本博客的所有分析都是在持久层接口以及接口中的方 ...