zoukankan      html  css  js  c++  java
  • hdu 6000 Wash

    题意:L件衣服,N个洗衣机,M个烘干机,给出每个洗衣机洗一件衣服的时间和烘干机烘干一件衣服的时间,问需要的最少时间是多少

    思路:贪心+优先队列,光想着暴力找出前L个时间了。。用优先队列可以快速找到每一件衣服出来的时间,然后我们可以同样知道在前L个时刻甩干机是工作的,那肯定是倒着来

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 const int N=1e6+10;
     5 
     6 int L,n,m;
     7 ll c[N];
     8 struct node{
     9     ll v,base;
    10     node(ll x,ll y){
    11         v=x;base=y;
    12     }
    13     bool operator<(const node &a) const {
    14         return v>a.v;
    15     }
    16 };
    17 priority_queue<node>q1,q2;
    18 int main(){
    19     int t;
    20     int k=1;
    21     cin>>t;
    22     while(t--){
    23         while(!q1.empty()) q1.pop();
    24         while(!q2.empty()) q2.pop();
    25         scanf("%d%d%d",&L,&n,&m);
    26         for(int i=1;i<=n;i++){
    27             ll x;
    28             scanf("%lld",&x);
    29             q1.push(node(x,x));
    30         }
    31         for(int i=1;i<=m;i++){
    32             ll x;
    33             scanf("%lld",&x);
    34             q2.push(node(x,x));
    35         }
    36         for(int i=0;i<L;i++){
    37             node x=q1.top();q1.pop();
    38             c[i]=x.v;
    39             x.v+=x.base;
    40             q1.push(x);
    41         }
    42         ll sum=0;
    43         for(int i=L-1;i>=0;i--){
    44             node x=q2.top();q2.pop();
    45             sum=max(sum,x.v+c[i]);
    46             x.v+=x.base;
    47             q2.push(x);
    48         }
    49         printf("Case #%d: %lld
    ",k++,sum);
    50     }
    51 }
  • 相关阅读:
    zen_cart 支付提前生成订单
    SSL加密过程
    建立自己的代码库
    自动代码工具
    mssqlserver 学习资源
    自己动手写操作系统(1)
    Windows Phone 7 优秀开源项目收集
    正则表达式工具
    .net framework source code
    vs2012 打包应用程序(创建部署/安装包)
  • 原文地址:https://www.cnblogs.com/hhxj/p/7525875.html
Copyright © 2011-2022 走看看