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

分析:

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

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

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

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
const double eps = 1e-8;
inline int dcmp(double a, double b){
if(fabs(a - b) < eps) return 0;
return a > b ? 1 : -1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 1000000 + 10;
const int MAXT = 10000 + 10;
using namespace std;
struct Node{
LL len, et;
Node(LL l, LL t):len(l), et(t){}
bool operator < (const Node& rhs)const{
return et > rhs.et;
}
};
LL washet[MAXN];
priority_queue<Node> q;
int main(){
int T;
scanf("%d", &T);
int kase = 0;
while(T--){
while(!q.empty()) q.pop();
int L, N, M;
scanf("%d%d%d", &L, &N, &M);
LL x;
for(int i = 0; i < N; ++i){
scanf("%lld", &x);
q.push(Node(x, x));
}
for(int i = 0; i < L; ++i){
Node top = q.top();
q.pop();
washet[i] = top.et;
q.push(Node(top.len, top.et + top.len));
}
while(!q.empty()) q.pop();
for(int i = 0; i < M; ++i){
scanf("%lld", &x);
q.push(Node(x, x));
}
LL ans = 0;
for(int i = L - 1; i >= 0; --i){
Node top = q.top();
q.pop();
ans = max(ans, washet[i] + top.et);
q.push(Node(top.len, top.et + top.len));
}
printf("Case #%d: %lld\n", ++kase, ans);
}
return 0;
}

最新文章

  1. centos 7.2 网卡配置文件 及 linux bridge的静态配置
  2. [UCSD白板题] Huge Fibonacci Number modulo m
  3. 添加html元素
  4. windows安装TortoiseGit详细使用教程
  5. hdu 2042
  6. BarTender破解问题
  7. javascript QUnit 单元测试
  8. Java [leetcode 21]Merge Two Sorted Lists
  9. LR如何监控tomcat性能
  10. [Google Codejam] Round 1A 2016 - The Last Word
  11. (转)java之Spring(IOC)注解装配Bean详解
  12. MySQL架构备份之M-S-S级联备份
  13. 缓存:前端页面缓存、服务器缓存(依赖SQL)MVC3
  14. 执行一个内容为SQL语句的字符串
  15. springboot2.0添加logback
  16. CentOS双机中Docker下安装Mysql并配置互为主从模式
  17. B1010.一元多项式求导
  18. 2015 年度新增开源软件排名 TOP 100 - 开源中国社区
  19. 关于bootstrap Modal弹窗 滚动条的问题
  20. Android-卖票案例static-不推荐此方式

热门文章

  1. ApacheDbUtilsUpdate
  2. C++中的四种类型转换运算符static_cast、dynamic_cast、const_cast和reinterpret_cast的使用
  3. Python 面试问答 Top 25
  4. 更换JAVA程序的界面风格
  5. 【AOP】在Aspect中无法获取实现类方法的注解
  6. 初识IntPtr------转载
  7. Vue 路由组件
  8. 三、多线程基础-自旋_AQS_多线程上下文
  9. DICOM的Worklist服务
  10. Day3-H-Alice and Bob HDU4268