# Wash

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 64000/64000 K (Java/Others)
Total Submission(s): 1250    Accepted Submission(s): 331

Problem Description
Mr.Panda is about to engage in his favourite activity doing laundry! He’s brought L indistinguishable loads of laundry to his local laundromat, which has N washing machines and M dryers.The

Input
The first line of the input gives the number of test cases, T.
T test cases follow. Each test case consists of three lines. The first line contains three integer L, N, and M.
The second line contains N integers

Output
For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the minimum time it will take Panda to finish his laundry.

## limits

Sample Input
2 1 1 1 1200 34 2 3 2 100 10 1 10 10

Sample Output
Case #1: 1234 Case #2: 12

Source

第一阶段，正着贪心，用set或优先队列维护，处理出每件衣服出来的时间。

第二阶段，倒着贪心，用set或优先队列维护，然后维护最大值。

 1 #include <bits/stdc++.h>
2
3 using namespace std;
4
5 #define MP make_pair
6 #define PB push_back
7 typedef long long LL;
8 typedef pair<int,int> PII;
9 const double eps=1e-8;
10 const double pi=acos(-1.0);
11 const int K=1e6+7;
12 const int mod=1e9+7;
13
14 namespace fastIO{
15     #define BUF_SIZE 100000
16     bool IOerror=0;
17     inline char nc(){
18         static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
19         if(p1==pend){
20             p1=buf;
22             if(pend==p1){
23                 IOerror=1;
24                 return -1;;
25             }
26         }return *p1++;
27     }
28     inline bool blank(char ch){
29         return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';
30     }
32         char ch;
33         while(blank(ch=nc()));
34         if(IOerror)return 0;
35         for(x=ch-'0';(ch=nc())>='0'&&ch<='9';x=x*10+ch-'0');
36         return 1;
37     }
38     #undef BUF_SIZE
39 };
40 using namespace fastIO;
41
42 struct node
43 {
44     LL id,end;
45     node(){}
46     node(LL x,LL y){id=x,end=y;}
47     bool operator < (const node &ta) const
48     {
49         return end>ta.end||(end==ta.end&&id<ta.id);
50     }
51 };
52 int n,m,l,ta[K],tb[K];
53 LL ed[K];
54 priority_queue<node>pa,pb;
55
56 int main(void)
57 {
58     //freopen("in.acm","r",stdin);
60     while(t--)
61     {
62         LL ans=0;
63         while(pa.size())pa.pop();
64         while(pb.size())pb.pop();
66         for(int i=1;i<=n;i++)
68         for(int i=1;i<=l;i++)
69         {
70             LL tm=pa.top().end,id=pa.top().id;
71             ed[i]=tm;
72             pa.pop(),pa.push(node(id,tm+ta[id]));
73         }
74         for(int i=1;i<=m;i++)
76         for(int i=l;i;i--)
77         {
78             LL tm=pb.top().end,id=pb.top().id;
79             ans=max(ans,ed[i]+tm);
80             pb.pop(),pb.push(node(id,tm+tb[id]));
81         }
82         printf("Case #%d: %lld\n",cs++,ans);
83     }
84     return 0;
85 }

posted @ 2017-10-18 15:37  weeping  阅读(510)  评论(0编辑  收藏  举报