zoukankan      html  css  js  c++  java
  • HDU 6000

    /*
    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
    ", tt, ans);
        }
    }
    

      

  • 相关阅读:
    监听本机tcp和udp的端口
    sysstat-----获取服务器负载历史记录
    inode索引详解
    tcpdump详解
    Windws Server 2008 R2 WEB环境配置之IIS7/IIS7.5+FastCGI+PHP 5.6.4+MYSQL+phpMyAdmin
    echo 命令
    带宽、流量、下载速度之间的换算
    windows 下解决 Time_Wait 和 CLOSE_WAIT 方法
    LNMP环境部署
    关于旅行
  • 原文地址:https://www.cnblogs.com/nicetomeetu/p/7496144.html
Copyright © 2011-2022 走看看