HDU6000-Wash

来源:互联网 发布:logo软件中文版下载 编辑:程序博客网 时间:2024/06/06 04:42

Wash

                                                                 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 64000/64000 K (Java/Others)
                                                                                               Total Submission(s): 569    Accepted Submission(s): 149


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


1T100.
1L106.
1N,M105.
1Wi,Di109.
 

Sample Input
21 1 11200342 3 2100 10 110 10
 

Sample Output
Case #1: 1234Case #2: 12
 

Source
2016 CCPC-Final
 

Recommend
jiangzijing2015
 

题意:有L件衣服,有n 个洗衣机,m 个烘干机,告诉你每个洗衣机的洗衣服的时间,和每个烘干机的烘干时间, 每个机器 、一个时间段只能处理一件衣服,问洗完这L件衣服最短时间是多少

解题思路:先求出每一件衣服最早的洗好的时间。然后在烘干,最后一件时间要尽量少,因此最晚洗好的时间用第一个烘干机


#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <map>#include <set>#include <cmath>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;int l, n, m;struct node{LL x, y;friend bool operator<(node a,node b){return a.x > b.x;}}pre;LL a[1000009],ma;priority_queue <node>q1, q2;int main(){int t, cas = 0;scanf("%d", &t);while (t--){scanf("%d %d %d", &l, &n, &m);while (!q1.empty()) q1.pop();while (!q2.empty()) q2.pop();for (int i = 0; i < n; i++){scanf("%lld", &pre.x);pre.y = pre.x;q1.push(pre);}for (int i = 0; i < m; i++){scanf("%lld", &pre.x);pre.y =pre.x;q2.push(pre);}for (int i = 0; i < l; i++){pre = q1.top();a[i] = pre.x;pre.x += pre.y;q1.pop();q1.push(pre);}ma = 0;for (int i = l - 1; i >= 0; i--){pre = q2.top();ma = max(ma, a[i] + pre.x);pre.x += pre.y;q2.pop();q2.push(pre);}printf("Case #%d: %lld\n", ++cas, ma);}return 0;}

原创粉丝点击