hduoj 6000 && 2016CCPC-final B. Wash(贪心)
2017-11-25 18:15
260 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6000
先求出所有衣服单独洗完的最快时间再求出所有衣服单独烘干的最快时间
之后两个拼在一起就行了,当然是当前最慢的和当前最快的拼
#include<stdio.h> #include<queue> #include<functional> using namespace std; #define LL long long typedef struct Res { LL t, id; bool operator < (const Res &b) const { if(t>b.t) return 1; return 0; } }Res; Res now; priority_queue<Res> q; LL a[100005], b[100005], t1[1000005], t2[1000005]; int main(void) { LL ans; int T, L, n, m, i, cas; cas = 1; scanf("%d", &T); while(T--) { scanf("%d%d%d", &L, &n, &m); for(i=1;i<=n;i++) scanf("%lld", &a[i]); for(i=1;i<=m;i++) scanf("%lld", &b[i]); while(q.empty()==0) q.pop(); for(i=1;i<=n;i++) { now.t = a[i], now.id = i; q.push(now); } for(i=1;i<=L;i++) { now = q.top(); q.pop(); t1[i] = now.t; now.t += a[now.id]; q.push(now); } while(q.empty()==0) q.pop(); for(i=1;i<=m;i++) { now.t = b[i], now.id = i; q.push(now); } for(i=1;i<=L;i++) { now = q.top(); q.pop(); t2[i] = now.t; now.t += b[now.id]; q.push(now); } ans = 0; for(i=1;i<=L;i++) ans = max(t1[i]+t2[L-i+1], ans); printf("Case #%d: %lld\n", cas++, ans); } return 0; }
相关文章推荐
- hdu 6000 Wash(2016 CCPC-Final)
- 【2016 CCPC-Final】B - Wash
- 2016 CCPC-Final B - Wash (优先队列)
- CCPC-final 2016 B - wash
- 2017 CCPC 秦皇岛 & ZOJ 3987 - Numbers (贪心+大数)
- 2016 CCPC-Final A - The Third Cup is Free
- HDU 5933 && 2016CCPC杭州 A: ArcSoft's Office Rearrangement
- HDU 5935 && 2016CCPC杭州 C: Car
- HDU 6000 Wash (优先队列-贪心)
- bzoj 5088: HDU 6000 Wash 堆+贪心
- HDU 5942 && 2016CCPC杭州 J: Just a Math Problem(莫比乌斯函数)
- HDU 6000 Wash【优先队列优化贪心】【最大值+最小值】
- hdu 6000 Wash 贪心
- HDU 5936 && 2016CCPC杭州 D: Difference(折半枚举)
- 【HDU 6000 Wash】优先队列 & 贪心
- 2017 CCPC Final B Wash
- 【HDU5932 2016CCPC东北地区大学生程序设计竞赛 - 重现赛 K】【树上背包 贪心乱搞】Backpack on Tree 物品成本只有12345下的树上背包
- Problem D. Ice Cream Tower(2016 China-Final)【二分答案+贪心检验】
- HDU 5937 && 2016CCPC杭州 E: Equation(DFS)
- 2016 CCPC Hangzhou Onsite A - ArcSoft's Office Rearrangement(HDU 5933) (贪心,模拟)