zoukankan      html  css  js  c++  java
  • HDU

    题意:已知有L件衣服,M个洗衣机,N个烘干机,已知每个机器的工作时间,且每个机器只能同时处理一件衣服,问洗烘完所有衣服所需的最短时间。

    分析:

    1、优先队列处理出每件衣服最早的洗完时间。

    2、优先队列处理出每件衣服最早的烘完时间。

    3、用最大的洗完时间与最小的烘完时间相加,取最大值。

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cctype>
    #include<cmath>
    #include<iostream>
    #include<sstream>
    #include<iterator>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<set>
    #include<map>
    #include<stack>
    #include<deque>
    #include<queue>
    #include<list>
    #define Min(a, b) ((a < b) ? a : b)
    #define Max(a, b) ((a < b) ? b : a)
    const double eps = 1e-8;
    inline int dcmp(double a, double b){
        if(fabs(a - b) < eps) return 0;
        return a > b ? 1 : -1;
    }
    typedef long long LL;
    typedef unsigned long long ULL;
    const int INT_INF = 0x3f3f3f3f;
    const int INT_M_INF = 0x7f7f7f7f;
    const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
    const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
    const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
    const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
    const int MOD = 1e9 + 7;
    const double pi = acos(-1.0);
    const int MAXN = 1000000 + 10;
    const int MAXT = 10000 + 10;
    using namespace std;
    struct Node{
        LL len, et;
        Node(LL l, LL t):len(l), et(t){}
        bool operator < (const Node& rhs)const{
            return et > rhs.et;
        }
    };
    LL washet[MAXN];
    priority_queue<Node> q;
    int main(){
        int T;
        scanf("%d", &T);
        int kase = 0;
        while(T--){
            while(!q.empty()) q.pop();
            int L, N, M;
            scanf("%d%d%d", &L, &N, &M);
            LL x;
            for(int i = 0; i < N; ++i){
                scanf("%lld", &x);
                q.push(Node(x, x));
            }
            for(int i = 0; i < L; ++i){
                Node top = q.top();
                q.pop();
                washet[i] = top.et;
                q.push(Node(top.len, top.et + top.len));
            }
            while(!q.empty()) q.pop();
            for(int i = 0; i < M; ++i){
                scanf("%lld", &x);
                q.push(Node(x, x));
            }
            LL ans = 0;
            for(int i = L - 1; i >= 0; --i){
                Node top = q.top();
                q.pop();
                ans = max(ans, washet[i] + top.et);
                q.push(Node(top.len, top.et + top.len));
            }
            printf("Case #%d: %lld
    ", ++kase, ans);
        }
        return 0;
    }
    
  • 相关阅读:
    Navicat建表MySQL索引类型
    Feign调用全局异常处理解决
    ShardingJDBC、Mycat、drds对比
    MySQL之索引失效分析及优化相关
    SpringBoot2.X集成spring session redis实现session共享
    Redis的消息订阅/发布 Utils工具类
    MySQL索引类型区分
    handler使用(二)
    Android开发指南中文版(七)Content Providers
    Android消息处理(一)进程内通信
  • 原文地址:https://www.cnblogs.com/tyty-Somnuspoppy/p/7447287.html
Copyright © 2011-2022 走看看