Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
why wrong????????????#include<iostream> using namespace std; int n,h,h1,f[25],f1[25],time[25],time1[25],d[25],t[25]; int work(int a) { int res=0,w,v,i; for(i=0;i<a-1;i++) h1-=t[i]; while(h1>0) { w=0;v=-1; for(i=0;i<a;i++) if(f1[i]>w) { w=f1[i]; v=i; } if(w==0) break; res+=f1[v]; f1[v]-=d[v]; time1[v]++; h1--; } time1[0]+=h1; return res; }; int main() { int i,j,max,s; cin>>n; while(n) { cin>>h; h=h*12; for(i=0;i<n;i++) cin>>f[i]; for(i=0;i<n;i++) cin>>d[i]; for(i=0;i<n-1;i++) cin>>t[i]; max=0; memset(time,0,25*4); time[0]=h; for(i=0;i<n;i++) { for(j=0;j<n;j++) f1[j]=f[j],time1[j]=0; h1=h; s=work(n-i); if(s>max) { max=s; for(j=0;j<n;j++) time[j]=time1[j]; } else if(s==max) { for(j=0;j<n;j++) if(time[j]!=time1[j]) break; if(time[j]<time1[j]) for(;j<n;j++) time[j]=time1[j]; } if(h1>0) break; } for(i=0;i<n-1;i++) printf("%d, ",time[i]*5); printf("%d\n",time[i]*5); printf("Number of fish expected: %d\n\n",max); cin>>n; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator