【2016 CCPC-Final】B
来源:互联网 发布:临沂知豆电动汽车销售 编辑:程序博客网 时间:2024/06/06 10:40
https://vjudge.net/problem/Gym-101206B
L件衣服, n 个洗衣机, m 个烘干机, 给定每台洗衣机洗衣服的时间和每台烘干机烘干的时间, 每台机器一个时间段只能处理一件衣服。
求洗完L件衣服的最短时间?
使用priority_queue
先使用优先队列算出第i件衣服洗完的最短时间,
若要使洗+烘干的总时间最短,则最晚洗完的衣服应放到最快的烘干机中,
按照该原则依次更新答案。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <queue>#include <algorithm>using namespace std;int t,l,n,m;long long a[1000005];long long ans;struct Node{ long long Cost,Next; friend bool operator <(Node a,Node b){ return a.Next > b.Next; }};priority_queue <Node> q;int main(){ scanf("%d",&t); for (int k=1;k<=t;k++){ ans=0; scanf("%d%d%d",&l,&n,&m); Node tmp; long long x; while (!q.empty()) q.pop(); for (int i=0;i<n;i++){ scanf("%lld",&x); tmp.Cost=tmp.Next=x; q.push(tmp); } for (int i=0;i<l;i++){ tmp=q.top(); q.pop(); a[i]=tmp.Next; tmp.Next+=tmp.Cost; q.push(tmp); } while (!q.empty()) q.pop(); for (int i=0;i<m;i++){ scanf("%lld",&x); tmp.Cost=tmp.Next=x; q.push(tmp); } for (int i=l-1;i>=0;i--){ //注意循环顺序 tmp=q.top(); q.pop(); ans=max(ans,a[i]+tmp.Next); tmp.Next+=tmp.Cost; q.push(tmp); } printf("Case #%d: %lld\n",k,ans); }}
阅读全文
0 0
- 2016 CCPC-Final B
- 【2016 CCPC-Final】B
- CCPC-final 2016 B
- 2017 CCPC Final B Wash
- hduoj 6000 && 2016CCPC-final B. Wash(贪心)
- 2016 CCPC-Final A
- hdu 6000 Wash(2016 CCPC-Final)
- CCPC 2016 Final 【solve 6 of 12】
- HDU 6000(CCPC Final)
- CCPC FINAL 2017
- hdu 6004 Periodical Cicadas [2016 CCPC-Final F] [同余]
- 2017 CCPC秦皇岛 B
- 【2016-CCPC-B】高斯消元(Zhu and 772002,hdu 5833)
- 2016CCPC东北-B.Mr. Frog’s Problem
- 2016ccpc杭州赛 hdu 5934 B.Bomb
- 2016CCPC
- CCPC Final 2017(Fair Lottery-单纯形)
- 2017哈尔滨ACM CCPC-final 总结
- Java基础——【习题三】数组练习题
- Python快速入门5--Python数据分析工具
- 【NOIP2013模拟联考3】恭介的法则(rule)
- Scott用户的表结构
- google 中国开发者网站
- 【2016 CCPC-Final】B
- 阻止对象可扩展性
- 从输入网址到显示网页-3-web缓存
- 将对象方法链化
- 数据库安全
- mysql数据库字符集限制主键长度的问题记录
- Android三种动画的原理
- 【nlp】文本情感分析
- 星球联盟