zoukankan      html  css  js  c++  java
  • 洗衣服

    洗L件衣服。有n台洗衣机和m台烘干机。

    第i台洗衣机洗一件衣服需要wi分钟,第i台烘干机烘干一件衣服需要di分钟。

    请问把所有衣服洗干净并烘干,最少需要多少时间?

    先处理出单独洗i件衣服所需的最短时间f[i]

    单独烘i件衣服所需的最短时间g[i]

    ans=max{g[i]+f[n-i+1]}

    肯定是边洗衣服边烘干洗过的衣服

    肯定至少有一件衣服(第一件),洗出来的时间过长,导致烘干机要闲着等

    这就浪费了时间导致烘干的总时间大于f[n]

    洗完这一件衣服后继续烘干剩下的(n-i+1)件衣服

    所以ans=洗完这件衣服的时间+烘干剩下的衣服的时间

    由于有多件衣服会拖时间,所以ans取最大值

    scanf("%lld%lld%lld",&l,&n,&m);
        for (int i=1;i<=n;++i){
            LL x;
            scanf("%lld",&x);
            q.push(make_pair(x,x));
        }
        for (int i=1;i<=l;++i){
            LL x=q.top().first,y=q.top().second;q.pop();
            c[u]=x;
            q.push(make_pair(x+y,y));
        }
        while (!q.empty()) q.pop();
        for (int i=1;i<=m;++i){
            LL x;
            scanf("%lld",&x);
            q.push(make_pair(x,x));
        }
        for (int i=l;i>=1;--i){
            LL x=q.top().first,y=q.top().second;q.pop();
            ans=max(ans,c[u]+x);
            q.push(make_pair(x+y,y));
        }
        printf("%lld
    ",ans);
    
  • 相关阅读:
    A. Vanya and Table
    B. Chris and Magic Square
    A. Bus to Udayland
    关于cout输出精度问题
    1087 1 10 100 1000
    1080 两个数的平方和
    CODE[VS] 1842 递归第一次
    CODE[VS] 1501 二叉树最大宽度和高度
    少年中国说
    CODE[VS] 1475 m进制转十进制
  • 原文地址:https://www.cnblogs.com/Doingdong/p/10710103.html
Copyright © 2011-2022 走看看