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 ...
随机推荐
- android下创建文件夹和修改其权限的方法
原文:http://www.cnblogs.com/wanqieddy/archive/2011/12/28/2304906.html 由于工作的需要,今天研究了在android下创建文件夹和修改其权 ...
- rem与部分手机 字体偏大问题
原因是部分手机自己设置了巨无霸字体.
- QT5静态编译工程(arm交叉编译)
1.首先,QT编译环境默认是动态库,要编译静态程序是不可能的,所以要下载QT源码,重新编译QT编译环境 2.下载QT源码(5.13版本):http://download.qt.io/developme ...
- html常用整理
视频链接:https://www.bilibili.com/video/av5862916?from=search&seid=12139895566389560177 我的第一个html &l ...
- 「国家集训队」Crash的数字表格
题目描述 求(对 \(20101009\) 取模,\(n,m\le10^7\) ) \[\sum_{i=1}^n\sum_{j=1}^m\operatorname{lcm}(i,j)\] 大体思路 推 ...
- php后门拿下当前目录
Weevely是一个模拟类似telnet的连接的隐形PHP网页shell.它是Web应用程序后期开发的必备工具,可以作为隐形后门程序,也可以作为一个web外壳来管理合法的Web帐户,甚至可以免费托管. ...
- CF 1278C Berry Jam 题解
Forewords 说实话我是被图吸引进来的23333,图画的真的挺好看. 题意 你从一个梯子下到地下室,梯子左右两边各有 \(n\) 瓶果酱排成一排,果酱口味为草莓味或蓝莓味,你每次只能吃你左边或右 ...
- Vue Element-Ui 改变el-Input背景样式
Element-ui是一个非常好的UI设计模块,它提供给我们很多好看的按钮样式,非常适用于快速搭建UI,下面说说如果使用了element-ui之后,要更改它默认的el-Input样式应该怎么操作. 使 ...
- Intellij Idea webstorm 激活
参考: 最新破解 https://www.cnblogs.com/litterCoder/p/12175461.html 推荐 https://mp.weixin.qq.com/s/zxfDAlN8G ...
- 图解Mybatis框架原理及使用
1.前言 努力学习完ssm框架之后,终于也成功的把三大框架的使用以及配置文件细节忘得一干二净.为了努力捡起来以及方便今后的复习,决定写一篇博客记录一下. 本博客的所有分析都是在持久层接口以及接口中的方 ...