HDU 6000 - Wash

/*
HDU 6000 - Wash [ 贪心 ]
题意:
	L 件衣服,N 个洗衣机,M 个烘干机,给出每个洗衣机洗一件衣服的时间和烘干机烘干一件衣服的时间,问需要的最少时间是多少
分析:
	先求出L件衣服最优洗衣时间的数组,再求出最优烘干时间的数组
	然后排序按最小值+最大值的思路贪心,取最大值
	可以看成排序后两数组咬合
*/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 1e5+5;
const int MAXL = 1e6+5;
struct Node {
    LL x; int y;
    friend operator < (Node a, Node b) {
        if (a.x == b.x) return a.y > b.y;
        return a.x > b.x;
    }
};
priority_queue<Node> Q;
int t, l, n, m;
int w[N], d[N];
LL a[MAXL], b[MAXL];
void solve(int w[], int n, LL a[])
{
    while (!Q.empty()) Q.pop();
    for (int i = 1; i <= n; i++) Q.push(Node{w[i], w[i]});
    for (int i = 1; i <= l; i++)
    {
        Node tmp = Q.top(); Q.pop();
        a[i] = tmp.x;
        tmp.x += tmp.y;
        Q.push(tmp);
    }
}
int main()
{
    scanf("%d", &t);
    for (int tt = 1; tt <= t; tt++)
    {
        scanf("%d%d%d", &l, &n, &m);
        for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
        for (int i = 1; i <= m; i++) scanf("%d", &d[i]);
        solve(w, n, a);
        solve(d, m, b);
        LL ans = 0;
        for (int i = 1; i <= l; i++)
        {
            ans = max(ans, a[i] + b[l-i+1]);
        }
        printf("Case #%d: %lld\n", tt, ans);
    }
}

  

转载于:https://www.cnblogs.com/nicetomeetu/p/7496144.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值