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 |
Re:请大虾帮忙,,绝对奇怪的问题!!!附代码;In Reply To:请大虾帮忙,,绝对奇怪的问题!!!附代码; Posted by:lbp at 2005-09-16 13:13:19 > #include <stdio.h> > #include<iostream.h> > int n,h; > int f[26],d[26],t[26]; > int ff[26],tt[26]; > int best_t[26],max_fish; > > int main() > { > int i,j,k,left_time,fish; > > cin>>n; > while(n>0) > { > cin>>h; > for(i=1;i<=n;i++) > { > cin>>f[i]; > } > for(i=1;i<=n;i++) > { > cin>>d[i]; > } > t[1] = 0; > for(i=2;i<=n;i++) > { > cin>>t[i]; > t[i] += t[i-1]; > } > max_fish = 0; > for(k=n;k>=1;k--) > { > fish = 0; > left_time = h*60-t[k]*5;////// > for(i=1;i<=n;i++) > { > ff[i] = f[i]; > tt[i] = 0; > } > while(left_time > 0) > { > j = 1; > for(i=1;i<=k;i++) > { > if(ff[i] > ff[j]) > j = i; > } > if(ff[j] == 0)////鱼都没了; > break; > tt[j] += 5; > fish += ff[j]; > ff[j] -= d[j]; > if(ff[j] <=0) > ff[j] = 0; > left_time -= 5; > } > //left_time>=0; > tt[1] += left_time; > if(fish > max_fish)/// = ?????如何抉择呢?? > { > for(i=1;i<=n;i++) > best_t[i] = tt[i]; > max_fish = fish; > } > else > if( fish==max_fish ) > { > for(i=1;i<=n;i++) > if(best_t[i] <=tt[i])//奇怪之处:改成best_t[i] <tt[i]就过不了!!!! > break; > if(i != n+1) > { > for(i=1;i<=n;i++)best_t[i] = tt[i]; > max_fish = fish; > } > } > }////////////////////////////////// > for(i=1;i<n;i++) > { > cout<<best_t[i]<<", "; > } > cout<<best_t[n]<<endl; > > cout<<"Number of fish expected: "<<max_fish<<endl; > cout<<endl; > 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