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

题意:已知有L件衣服,M个洗衣机,N个烘干机,已知每个机器的工作时间,且每个机器只能同时处理一件衣服,问洗烘完所有衣服所需的最短时间. 分析: 1.优先队列处理出每件衣服最早的洗完时间. 2.优先队列处理出每件衣服最早的烘完时间. 3.用最大的洗完时间与最小的烘完时间相加,取最大值. #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<cmath&…
/* HDU 6000 - Wash [ 贪心 ] 题意: L 件衣服,N 个洗衣机,M 个烘干机,给出每个洗衣机洗一件衣服的时间和烘干机烘干一件衣服的时间,问需要的最少时间是多少 分析: 先求出L件衣服最优洗衣时间的数组,再求出最优烘干时间的数组 然后排序按最小值+最大值的思路贪心,取最大值 可以看成排序后两数组咬合 */ #include <bits/stdc++.h> using namespace std; #define LL long long const int N = 1e5+…
题目:http://acm.hdu.edu.cn/showproblem.php? pid=5360 题意:beta有n个朋友,beta要邀请他的朋友go hiking,已知每一个朋友的理想人数[L,R](现有L~R个人准备去,那么这个朋友就去). 求最多有多少人去. 及beta邀请朋友的顺序. 分析:每次邀请人的最优解就是:选会去的人里面R最小的那个人. 代码实现的话,cur代表已经准备go hiking的人数,每次将全部L<=cur的人放进优先队列,选出R最小的那个. 假设队列为空,那么剩下…
HDU 5289 - Assignment http://acm.hdu.edu.cn/showproblem.php?pid=5289 Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task t…
题意: 给定N个无序区间. 对合法区间的定义是: 在这个区间之前已经选出了至少l个合法区间,最多选出了r个合法区间.则该区间为合法区间. 输出最多能挑选出多少个合法区间,并输出合法区间的数量. 思路: 先对原来给定的区间按照l从小到达排序. 然后从选了0个合法区间开始,每次在队列中加入l小于等于之前已选合法区间数的区间加入队列, 按照r从小到大进行优先排列.每次从队列中拿出top,当拿出的区间r小于已经找到的区间数时,我们把他放到临时数组里边.每次选出一个合法区间就更新一下队列的成员,将l小于等…
HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Description WANGPENG is a freshman. He is requested to have a physical examination when entering the university. Now WANGPENG arrives at the hospital. Er-.. Th…
题目地址:http://www.51cpc.com/web/problem.php?id=1587 Summarize: 优先队列&贪心: 1. 按价值最高排序,价值相同则按完成时间越晚为先: 2. 使用数组记录时间节点是否有任务,时间节点从最晚倒序遍历: 3. 若此刻时间节点有任务,则从此时间节点往前推,直到某一刻无任务,否则放弃该任务: 附贪心代码: (此处并未使用优先队列,以vector代替) #include<iostream> #include<algorithm>…
以下代码可对结构体数组中的元素进行排序,也差不多算是一个小小的模板了吧 #include<iostream> #include<algorithm> using namespace std; struct node { int x; int y; bool operator<(const node &a) const//此操作是对操作符"<"进行重构 { return x < a.x;//对结构体数组x进行从大到小排序 // retur…
Buy and Resell Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2441    Accepted Submission(s): 924 Problem Description The Power Cube is used as a stash of Exotic Power. There are n cities numbe…
Problem Description Mr.Panda is about to engage in his favourite activity doing laundry! He's brought L indistinguishable loads of laundry to his local laundromat, which has N washing machines and M dryers.The ith washing machine takes Wi minutes to…