zoukankan      html  css  js  c++  java
  • Wash Gym

    Wash Gym - 101206B 

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <string>
     5 #include <vector>
     6 #include <map>
     7 #include <set>
     8 #include <list>
     9 #include <deque>
    10 #include <queue>
    11 #include <stack>
    12 #include <cstdlib>
    13 #include <cstdio>
    14 #include <cmath>
    15 #include <iomanip>
    16 #define ull unsigned long long
    17 #define ll long long
    18 #define pb push_back
    19 #define tle ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    20 using namespace std;
    21 const int mod = 998244353;
    22 const int mxn = 1e6 +7;
    23 ll _,n,m,t,k,u,v,ans,cnt,ok,lim;
    24 ll w[mxn] , cost[mxn] ,  far[mxn] , siz[mxn];
    25 char ch;
    26 #define lc now<<1
    27 #define rc now<<1|1
    28 string str ;
    29 ll a[mxn];
    30 struct node
    31 {
    32     ll x,y;
    33     bool operator <(const node & a) const {
    34         return x>a.x;
    35     }
    36 }tmp;
    37 priority_queue<node>q,p;
    38 int main()
    39 {tle;
    40     int Case = 1 ;
    41     for(cin>>t;t;t--)
    42     {
    43         cin>>k>>n>>m;
    44         while(!q.empty()) q.pop();
    45         while(!p.empty()) p.pop();
    46         for(int i=1;i<=n;i++)
    47         {
    48             cin>>u;
    49             q.push({u,u});
    50         }
    51         for(int i=1;i<=m;i++)
    52         {
    53             cin>>u;
    54             p.push({u,u});
    55         }
    56         for(int i=1;i<=k;i++) /// 记录分别洗完L箱衣服的时间
    57         {
    58             tmp = q.top() ; q.pop() ;/// 每次选择最早结束的机器,因为
    59             a[i] = tmp.x ;
    60             q.push( {tmp.x+tmp.y,tmp.y} );/// 将洗完下一箱衣服的时间压进去
    61         }
    62 
    63         ll ans = 0 ;
    64         for(int i=k;i>=1;i--)
    65         {
    66             tmp = p.top(); p.pop() ;
    67             ans = max(ans,tmp.x+a[i]);
    68             p.push({tmp.x+tmp.y,tmp.y});
    69         }
    70         cout<<"Case #"<<Case++<<": "<<ans<<endl;
    71     }
    72 }
    /// 逆序的原因可以这样想,如果先烘干先洗完的,那么,最后一个一定是满时间烘干,
    /// 而如果我们把最早洗完的用最慢的烘干机烘干,时间就会短很多
    /// 也就是最长烘干时间+最短洗涤时间即为完成最短时间
    所遇皆星河
  • 相关阅读:
    [CAMCOCO][C#]我的系统架构.服务器端.(一)
    开博啦,加油!!
    Django RestFul framework Serializer序列化器的使用(定义)
    Django项目快速搭建
    Django简介
    python搭建虚拟环境
    大专生自学web前端前前后后
    实现资源国际化
    利用ajax实现页面动态修改
    七牛使用
  • 原文地址:https://www.cnblogs.com/Shallow-dream/p/12833325.html
Copyright © 2011-2022 走看看