【vj链接】
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:
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! 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!
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.
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.
2
1 1 1
1200
34
2 3 2
100 10 1
10 10
Case #1: 1234
Case #2: 12
T ;//T组数据
L N M ;//L件衣服,N个洗衣机,M个烘干机
w1 w2 w3 ……;//N个洗衣机各自洗一件衣服所用的时间
d1 d2 d3 ……;//M个烘干机各自洗一件衣服所用的时间
一开始所有衣服都是待洗的,衣服之间没有区别,先洗后烘干。求处理完所有衣服的最早时间。
1、将洗衣机按照洗完下一件衣服的时间来排序,也就是洗完第一件衣服用w[i],第二件是2 * w[i]……
通过优先队列得到每件衣服最早洗完的时间。
2、对于烘干机来说,要使结束时间最早就要让最后一件衣服尽量早烘干,也就是每件衣服的烘干时间取max。
考虑两件衣服,洗完时间分别为w1
当w2-w1
AC代码
#include