HDU - 6000 Wash(优先队列+贪心)
题意:已知有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(优先队列+贪心)的更多相关文章
- HDU 6000 - Wash
/* HDU 6000 - Wash [ 贪心 ] 题意: L 件衣服,N 个洗衣机,M 个烘干机,给出每个洗衣机洗一件衣服的时间和烘干机烘干一件衣服的时间,问需要的最少时间是多少 分析: 先求出L件 ...
- hdu 5360 Hiking(优先队列+贪心)
题目:http://acm.hdu.edu.cn/showproblem.php? pid=5360 题意:beta有n个朋友,beta要邀请他的朋友go hiking,已知每一个朋友的理想人数[L, ...
- HDU 5289 Assignment [优先队列 贪心]
HDU 5289 - Assignment http://acm.hdu.edu.cn/showproblem.php?pid=5289 Tom owns a company and he is th ...
- HDU 5360 【优先队列+贪心】
题意: 给定N个无序区间. 对合法区间的定义是: 在这个区间之前已经选出了至少l个合法区间,最多选出了r个合法区间.则该区间为合法区间. 输出最多能挑选出多少个合法区间,并输出合法区间的数量. 思路: ...
- HDU 4442 Physical Examination(贪心)
HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Descripti ...
- 最高的奖励 - 优先队列&贪心 / 并查集
题目地址:http://www.51cpc.com/web/problem.php?id=1587 Summarize: 优先队列&贪心: 1. 按价值最高排序,价值相同则按完成时间越晚为先: ...
- POJ2431 优先队列+贪心 - biaobiao88
以下代码可对结构体数组中的元素进行排序,也差不多算是一个小小的模板了吧 #include<iostream> #include<algorithm> using namespa ...
- hdu3438 Buy and Resell(优先队列+贪心)
Buy and Resell Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- 【HDU 6000】Wash(贪心)
Problem Description Mr.Panda is about to engage in his favourite activity doing laundry! He's brough ...
随机推荐
- AD7705/TM7705使用注意事项
http://bbs.eeworld.com.cn/thread-66467-1-1.html 1 空闲是SCLK=1(C POA),DIN=1(因为写寄存器都是从写通讯寄存器开始,此时第8位必须为0 ...
- day21-Python运维开发基础(单个字符匹配 / 多字符匹配)
1. 正则表达式(单个字符匹配) # ### 正则表达式 => 单个字符匹配 import re """ lst = re.findall(正则表达式,字符串) & ...
- 使用IDEA查看数据库
emm...今天捣鼓了一下IDEA意外发现(原谅我后知后觉)不用Navicat也能查看数据库中的表,虽然可视化不如Navicat,但毕竟Navicat要钱,一些朋友也没有资源 = =,所以就记录并分享 ...
- 引入CSS的方式、link和@import的区别
引入CSS的方式有四种:内联方式.嵌入方式.链接方式.导入方式. 内联方式 内联方式指的是直接在 HTML 标签中的 style 属性中添加 CSS. <div style="back ...
- DRF项目之层级关系
一共分为四层关系. 第一层:视图 用来接收前端传递的参数,并实现业务逻辑相关的数据处理,并将数据通过创建序列化器对象的形式传递给序列化器. 第二层:序列化器 接收前端传递的数据,并将数据进行序列化操作 ...
- 在ng-repeat 中使用 ng-click
angular 中使用 ng-repeat 过程中,有时需要绑定 事件 click ,使用ng-click ,但是并没有效果,此时应该使用 data-ng-click 替代 ng-click ,并且 ...
- 科软-信息安全实验1-ICMP重定向
目录 一 前言 二 Talk is cheap, show me the code 三 效果演示 四 遇到的问题&解决 一 前言 文章不讲解理论知识哈,想学习理论知识的,认真听课
- app自动化 - 元素定位不到?别慌,3大工具帮你搞定!
在日常的android app自动化测试工作当中,很多朋友在元素定位时,会遇到以下类似的报错: 然后会来问,这是啥情况? 一般情况下,都会送上以下亲切的关怀: 1)adb能识别到设备吗? 2)设备有被 ...
- python之常见模块(time,datetime,random,os,sys,json,pickle)
目录 time 为什么要有time模块,time模块有什么用?(自己总结) 1. 记录某一项操作的时间 2. 让某一块代码逻辑延迟执行 时间的形式 时间戳形式 格式化时间 结构化时间 时间转化 总结: ...
- Vim学习1移动光标
vim adventure上面做了大量练习,是个好软件只是需要收费 HJKLWBE 首先HJKL分别是移动上下左右的 H:光标左移 J:下移 K:上移 L:右移 W:跳转到下一个单词的第一个字,注意是 ...