【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

因为每件衣服都是没有区别的。
只有洗衣机不同会影响洗衣时间。
那么我们把每台洗衣机洗衣的时间一开始都加入到队列中。
比如{2,3,6,7}
这个队列里面的数字就代表了如果某件衣服用这台洗衣机洗的话,要在什么时刻洗好。
对于每一件衣服i。
取出队列的头。
这里为2
那么就a[i] = 2,表示第i件衣服最早在a[i] = 2时刻洗好
然后再把2+t[i]加入到队列中即{3,2+t[i],6,7} (这里t[i]即等于2)
每次都取出队头即可。

然后是烘干的过程。

贪心的方法是,最晚洗好的那一件衣服

(这里因为我们第一步贪心的时候,是顺序枚举每一件衣服的,所以最晚洗好的那一件衣服一定是a[L])

一定要用最快的烘干机去烘干它。

按照这个去贪心就好。

这个过程其实不是很好理解

代码中 取出最快的烘干机之后,把{temp.first+temp.second,temp.second}再次加入到队列中,实际含义

其实就是说,如果有另外一件衣服还要用这台机器烘干的话,那么得多出来temp.second的时间,让给前面

的衣服->但是也可能不用让,不用让也没事,那么之前得到的一定是更大的值.

这点是需要动脑子的地方。

【代码】

/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
6.use error MAX_VALUE?
7.use scanf instead of cin/cout?
8.whatch out the detail input require
*/
#include <bits/stdc++.h>
#define ll long long
using namespace std; const int N = 1e6+10; ll a[N];
int T,l,n,m;
priority_queue <pair<ll,ll> ,vector <pair<ll,ll> >,greater <pair<ll,ll> > > q; int main(){
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
#endif
int kase = 0;
ios::sync_with_stdio(0),cin.tie(0);
cin >> T;
while (T--){
cin >> l >> n >> m; for (int i = 1;i <= n;i++){
ll x;
cin >> x;
q.push({x,x});
} for (int i = 1;i <= l;i++){
a[i] = q.top().first;
pair<ll,ll> temp = q.top();
q.pop();
temp.first += temp.second;
q.push(temp);
} while (!q.empty()) q.pop(); for (int i = 1;i <= m;i++){
ll x;
cin >> x;
q.push(make_pair(x,x));
} ll ma = 0;
for (int i = l;i >= 1;i--){
pair <ll,ll> temp = q.top();
q.pop();
ma = max(ma,a[i]+temp.first);
temp.first+=temp.second;
q.push(temp);
}
while (!q.empty()) q.pop();
cout << "Case #"<<++kase<<": "<<ma<<endl;
} return 0;
}

【hdu 6000】Wash的更多相关文章

  1. 【HDU 6000】Wash(贪心)

    Problem Description Mr.Panda is about to engage in his favourite activity doing laundry! He's brough ...

  2. 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题

    [HDU  3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...

  3. 【HDU 5647】DZY Loves Connecting(树DP)

    pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS ...

  4. -【线性基】【BZOJ 2460】【BZOJ 2115】【HDU 3949】

    [把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最 ...

  5. 【HDU 2196】 Computer(树的直径)

    [HDU 2196] Computer(树的直径) 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 这题可以用树形DP解决,自然也可以用最直观的方法解 ...

  6. 【HDU 2196】 Computer (树形DP)

    [HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题 ...

  7. 【HDU 5145】 NPY and girls(组合+莫队)

    pid=5145">[HDU 5145] NPY and girls(组合+莫队) NPY and girls Time Limit: 8000/4000 MS (Java/Other ...

  8. 【hdu 3537】Daizhenyang's Coin

    Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...

  9. 【49.23%】【hdu 1828】Picture

    Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...

随机推荐

  1. Vue中对data的操作

    1. {{a}} var vm = new Vue({ el: '#app', data: { a: { a: 1, b: 2 } } })   vm.a.c = 'sadoisad' // 按理说是 ...

  2. 一招制胜---详解分布式系统里session同步

    一招制胜---详解分布式系统里session同步 几周前,有个盆友问老王,说现在有多台服务器,怎么样来解决这些服务器间的session同步问题?老王一下就来精神了,因为在n年以前,老王还在学校和几个同 ...

  3. leetcode笔记:Sort Colors

    一. 题目描写叙述 Given an array with n objects colored red, white or blue, sort them so that objects of the ...

  4. HDU - 2254 奥运 (求等比数列和)

    Description 北京迎来了第一个奥运会,我们的欢呼声响彻中国大地,所以今年的奥运金牌 day day up! 比尔盖兹坐上鸟巢里,手里摇着小纸扇,看的不亦乐乎,被俺们健儿的顽强拼搏的精神深深的 ...

  5. jQuery Easy UI ProgressBar(进度条)组件

    ProgressBar(进度条)组件,这个还是挺好玩的.我们在自己做点什么的时候常常能用到,比方上传下载文件.导入导出文档啊.加载网页等等. 应用场景非常多,使用起来还非常easy. 演示样例: &l ...

  6. jquery--延迟对象

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  7. vim 基础学习之普通模式

    .操作 = 操作符 + 动作 aaa bbb例如,d是删除命令,b是移动到距离光标最近的字符串开头当我们执行db的时候,就会删除光标(不包括光标位置)到最近字串开头之间的字符dj则会删除光标所在行以及 ...

  8. 全面了解Linux下Proc文件系统

    全面了解Linux下Proc文件系统   Proc是一个虚拟文件系统,在Linux系统中它被挂载于/proc目录之上.Proc有多个功能 ,这其中包括用户可以通过它访问内核信息或用于排错,这其中一个非 ...

  9. Shiro + SSM(框架) + Freemarker(jsp)

    Shiro + SSM(框架) + Freemarker(jsp)讲解的权限控制Demo,还不赶快去下载? 我们知道Ajax不能做页面redirect和forward跳转,所以Ajax请求假如没登录, ...

  10. [Redux-Observable && Unit Testing] Use tests to verify updates to the Redux store (rxjs scheduler)

    In certain situations, you care more about the final state of the redux store than you do about the ...