zoukankan      html  css  js  c++  java
  • hdu 6000

    http://acm.hdu.edu.cn/showproblem.php?pid=6000

    题意:有L件衣服,n个洗衣机,m个烘干机

    然后求最少的把所以衣服洗完烘干的时间

    思路:先用优先队列把所有洗完衣服的时间求出

    然后,最先洗完的衣服放时间最多的洗衣机,这样可以使最后一件衣服尽早洗

     1 #include <stdio.h>
     2 #include <string.h>
     3 #include <queue>
     4 #include <vector>
     5 using namespace std;
     6 struct Node{
     7     long long x,y;
     8      bool operator < (const Node& rhs) const {
     9         return y > rhs.y;
    10     }
    11 };
    12 priority_queue<Node >s;
    13 priority_queue<Node>p;
    14 long long a[1000005];
    15 
    16 
    17 int main()
    18 {
    19    // freopen("in.txt","r",stdin);
    20     int t;
    21     int l,n,m;
    22     long long ans;
    23     int cnt = 1;
    24     scanf("%d",&t);
    25     while(t--)
    26     {
    27         Node tmp;
    28         ans  = 0;
    29         scanf("%d%d%d",&l,&n,&m);
    30         while(!s.empty())
    31             s.pop();
    32         while(!p.empty())
    33             p.pop();
    34         for(int i = 0;i<n;i++)
    35         {
    36             scanf("%lld",&tmp.x);
    37             tmp.y = tmp.x;
    38             s.push(tmp);
    39         }
    40         for(int i= 0;i<m;i++)
    41         {
    42             scanf("%lld",&tmp.x);
    43             tmp.y = tmp.x;
    44             p.push(tmp);
    45         }
    46         for(int i = 0;i<l;i++)
    47         {
    48             tmp = s.top();
    49             a[i] = tmp.y;
    50             tmp.y +=tmp.x;
    51             s.push(tmp);
    52             s.pop();
    53         }
    54         for(int i = l-1;i>=0;i--)
    55         {
    56             tmp = p.top();
    57             ans = max(ans,tmp.y+a[i]);
    58             tmp.y+=tmp.x;
    59             p.push(tmp);
    60             p.pop();
    61         }
    62         printf("Case #%d: %lld
    ",cnt++,ans);
    63     }
    64     return 0;
    65 }
  • 相关阅读:
    无线桥接(WDS)如何设置?
    Linux内核的整体架构简介
    Efuse--芯片存储
    Linux下编写和加载 .ko 文件(驱动模块文件)
    统计难题
    最少拦截系统
    (比赛)B
    (比赛)A
    F
    K
  • 原文地址:https://www.cnblogs.com/Tree-dream/p/7476020.html
Copyright © 2011-2022 走看看