HDU 6000 Wash【优先队列优化贪心】【最大值+最小值】

Wash

Time Limit: 20000/10000 MS (Java/Others)

Memory Limit: 64000/64000 K (Java/Others)

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

 
     
2 1 1 1 1200 34 2 3 2 100 10 1 10 10

Sample Output

 
     
Case #1: 1234 Case #2: 12

Hint

jiangzijing2015

洗衣的最小值加甩干的最大值

#include 
#define INF 0x3f3f3f3f
#define ms(x,y) memset(x,y,sizeof(x))
using namespace std;

typedef long long ll;

const double pi = acos(-1.0);
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

ll w[100005],d[100005],a[1000005],b[1000005],l,m,n;

struct Node
{
	ll cost,next;
	Node(ll a,ll b)
	{
		cost = a;
		next = b;
	}
	Node(){}
	friend bool operator < (Node a, Node b)
	{
		return a.next > b.next;
	}
};

ll solve()
{
	ll ans = 0;
	priority_queue qa, qb;
	for(int i=0;i=0;i--)
	{
		Node tmp = qb.top();qb.pop();
		b[i] = tmp.next;

		//printf("b[%d] = %lld\n",i, b[i]);
		tmp.next += tmp.cost;
		qb.push(tmp);
		ans = max(ans, b[i] + a[i]);
	}
	return ans;
}

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int t;
	scanf("%d",&t);
	for(int cas = 1;cas <= t; cas++)
	{
		scanf("%lld%lld%lld",&l,&n,&m);
		for(int i=0;i

转载于:https://www.cnblogs.com/Archger/p/8451558.html

你可能感兴趣的:(HDU 6000 Wash【优先队列优化贪心】【最大值+最小值】)