hdu 6000 Wash

来源:互联网 发布:画巻展开效果 js 编辑:程序博客网 时间:2024/05/03 14:43
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 wash one load of laundry, and the ith dryer takes Di minutes to dry a load of laundry.
At any point in time, each machine may only be processing at most one load of laundry.
As one might expect, Panda wants to wash and then dry each of his L loads of laundry. Each load of laundry will go through the following steps in order:
1. A non-negative amount of time after Panda arrives at the laundromat, Panda places the load in an unoccupied washing machine i.
2. Wi minutes later, he removes the load from the washing machine, placing it in a temporary holding basket (which has unlimited space)
3. A non-negative amount of time later, he places the load in an unoccupied dryer j
4. Dj minutes later, he removes the load from the dryer Panda can instantaneously add laundry to or remove laundry from a machine. Help Panda minimize the amount of time (in minutes after he arrives at the laundromat) after which he can be done washing and drying all L loads of laundry!
Input
The first line of the input gives the number of test cases, T.
T test cases follow. Each test case consists of three lines. The first line contains three integer L, N, and M.
The second line contains N integers W1,W2,...,WN representing the wash time of each wash machine.
The third line contains M integers D1,D2,...,DM representing the dry time of each dryer.
Output
For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the minimum time it will take Panda to finish his laundry.
limits
∙1≤T≤100.
∙1≤L≤106.
∙1≤N,M≤105.
∙1≤Wi,Di≤109.
Sample Input
2
1 1 1
1200
34
2 3 2
100 10 1
10 10
Sample Output
Case #1: 1234

Case #2: 12

来一发 2017年第二A:题意:L堆衣服,N台洗衣机,M台脱水机,给出每台机器的每次工作的时间 Wi,Di。一台机器一次只能给一堆衣服工作,求洗完衣服最少需要多少时间。

毫不犹豫的来一发 最大加最小(最小洗完时间加最大的脱水时间)先分别计算每堆衣服的最少洗完时间,然后再用最小洗完时间加上需要最大的脱水时间。

#include <iostream>#include<stdio.h>#include<string.h>#include<queue>#include<algorithm>#define siz 1000005typedef long long ll;using namespace std;struct node{    ll cot;    int id;    bool operator <(const node &a) const    {        return a.cot<cot;    }};ll a[siz],b[siz],d[siz];int L,N,M;ll ans;void solve(){    node V,U;    ll time;    priority_queue<node>Q1,Q2;    for(int i=1; i<=N; i++)    {        U.cot =a[i], U.id =i;        Q1.push(U);    }    for(int i=1; i<=M; i++)    {        U.cot =b[i], U.id =i;        Q2.push(U);    }    for(int i=1; i<=L; i++) //洗衣服    {        V = Q1.top();        Q1.pop();        time = V.cot;        U.cot=V.cot+a[ V.id ], U.id =V.id;        Q1.push(U);        d[i] = time;    }    for(int i=L; i>=1; i--)  //脱水    {        V =Q2.top();        Q2.pop();        time = V.cot;        U.cot=V.cot+b[ V.id ], U.id =V.id;        Q2.push(U);        ans =max(ans,time+d[i]);    }    return;}int main(){    int T;    cin>>T;    for(int t=1; t<=T; t++)    {        scanf("%d %d %d",&L,&N,&M);        for(int i=1; i<=N; i++) scanf("%I64d",&a[i]);        for(int i=1; i<=M; i++) scanf("%I64d",&b[i]);        ans  = -1;        solve();        printf("Case #%d: %I64d\n",t,ans);    }    return 0;}



0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 cf与主机连接不稳定怎么办 穿越火线与主机连接不稳定怎么办 word被锁定无法编辑怎么办 平衡车系统乱了怎么办 监控老是滴滴的响怎么办 磁盘已满 文件未保存怎么办 cocos只有代码没有项目怎么办 电脑系统管理员密码忘记了怎么办 魔兽小队不显示职业颜色怎么办 魔兽多余的橙装怎么办? f117-f6不读硬盘怎么办 中飞院飞行学生停飞了怎么办 军人对你敬礼时怎么办 小孩抱着就睡放下就醒怎么办 着火了怎么办 我的世界 生存战争2感冒了怎么办 生存战争2吐了怎么办 我的世界hqm重置怎么办 不小心打了110怎么办 我的世界皮肤有黑影怎么办 我的世界字体变大了怎么办 生锈的铁钉扎了怎么办 每天晚上窗纱上老有蝙蝠倒挂怎么办 我的世界没有痒怎么办 七日杀被ban了怎么办 吕框箱子上保护摸撕不掉怎么办 我的世界开光影卡怎么办 我的世界买不了怎么办 我的世界延迟高怎么办 我的世界过于昂贵怎么办 白色麻布染上别的颜色怎么办 印度老山檀香开裂了怎么办 专升本没过线怎么办 西安公租房小孩上学怎么办 全民k歌直播没人怎么办 在全民直播没人看怎么办 皮肤又黄又粗怎么办 被强制消费后应怎么办? 当保安不发工资怎么办? 辅警改革流管员怎么办 退伍证上照片毁了怎么办