题意:已知有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;
}

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. app自动化 - 元素定位不到?别慌,3大工具帮你搞定!

    在日常的android app自动化测试工作当中,很多朋友在元素定位时,会遇到以下类似的报错: 然后会来问,这是啥情况? 一般情况下,都会送上以下亲切的关怀: 1)adb能识别到设备吗? 2)设备有被 ...

  2. Autoit里用多进程模拟多线程

      一直以来Autoit都不支持多线程,因此一些需要同时运行多个循环的操作也就无法实现.这个问题在其它的某些语言里也经常出现,解决的方法就是使用多进程. 所谓多进程,就是同时运行多个子进程,每个子进程 ...

  3. SystemVerilog基本语法总结(下)

    2018年IC设计企业笔试题解析-(验证方向) 1.请简述:定宽数组,动态数组,关联数组,队列四种数据类型的各自特点.解析:(1)定宽数组:其宽度在声明的时候就指定了,故其宽度在编译时就确定了.(2) ...

  4. Gridview的stretchMode详解附自动宽度

    <GridView android:id="@+id/grid" android:layout_width="fill_parent" android:l ...

  5. JAVA 集合 List 分组的两种方法

    CSDN日报20170219--<程序员的沟通之痛> [技术直播]揭开人工智能神秘的面纱 程序员1月书讯 云端应用征文大赛,秀绝招,赢无人机! JAVA 集合 List 分组的两种方法 2 ...

  6. NO18 linux开机自启动设置--开机流程--中文乱码--查看行数

    第八题:装完系统后,希望让网络文件共享服务NES,仅在3级别上开机自启动,该如何做? 解答:什么是开机自启动,在Linux下软件服务随系统启动而启动的配置. 方法一:文件配置法,可以把要启动的服务的命 ...

  7. 最新获取 QQ头像 和 昵称接口

    网上找来的测试可用... 获取QQ头像 http://q2.qlogo.cn/headimg_dl?bs=QQ号&dst_uin=QQ号&dst_uin=QQ号&;dst_ui ...

  8. python2学习------基础语法5(文件操作)

    1.文件内容读取 a.txt teestttttttttttttt teestttttttttttttt teestttttttttttttt teestttttttttttttt teesttttt ...

  9. 第3节 sqoop:6、sqoop的数据增量导入和数据导出

    增量导入 在实际工作当中,数据的导入,很多时候都是只需要导入增量数据即可,并不需要将表中的数据全部导入到hive或者hdfs当中去,肯定会出现重复的数据的状况,所以我们一般都是选用一些字段进行增量的导 ...

  10. Windows 与 Linux 、esxi下面查看内存容量和数量

    1. Windows 查看内存信息: > wmic MEMORYCHIP get BankLabel,DeviceLocator,Capacity,Speed 2. Linux 查看内存信息: ...