标签:sts void process min any nta problem strong search
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6000
题目:
Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 64000/64000 K (Java/Others)
Total Submission(s): 1250 Accepted Submission(s): 331
思路:
第一阶段,正着贪心,用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; 21 pend=buf+fread(buf,1,BUF_SIZE,stdin); 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 } 31 inline bool read(int &x){ 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); 59 int t,cs=1;read(t); 60 while(t--) 61 { 62 LL ans=0; 63 while(pa.size())pa.pop(); 64 while(pb.size())pb.pop(); 65 read(l),read(n),read(m); 66 for(int i=1;i<=n;i++) 67 read(ta[i]),pa.push(node(i*1LL,1LL*ta[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++) 75 read(tb[i]),pb.push(node(i*1LL,1LL*tb[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 }
hdu6000 Wash ccpc-20162017-finals B Wash
标签:sts void process min any nta problem strong search
原文地址:http://www.cnblogs.com/weeping/p/7686981.html