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 <memory.h> #include<iostream> using namespace std; int main() { int n,h,i,j,max,time; int t[25],f[26],d[26],lake[26][26],copyf[26]; cin>>n; while(n!=0) { cin>>h; memset( lake, 0,sizeof(lake)); memset(t,0,26); for(i=1;i<=n;i++) cin>>f[i]; for(i=1;i<=n;i++) cin>>d[i]; for(i=1;i<n;i++) cin>>t[i]; h=h*60; int fish[26]; memset(fish, 0, 26); for(j=1;j<=n;j++) { time=h; for(i=1;i<=j;i++) copyf[i]=f[i];//暂存f[]备用 for( i=1;i<j;i++) time-=t[i]*5; int k=1; max=copyf[1],k=1; for(int i=2;i<=j;i++)// 查找当前下一个5分钟各湖中的鱼数 if(copyf[i]>max) {max=copyf[i];k=i;} while(copyf[k]>0&&time>0) { lake[j][k]++; fish[j]+=copyf[k]; copyf[k]-=d[k]; time-=5; max=copyf[1],k=1; for(int i=2;i<=j;i++)// 查找当前下一个5分钟各湖中的鱼数 if(copyf[i]>max) {max=copyf[i];k=i;} } } max=fish[1]; int s=1; for(i=2;i<=n;i++) if(fish[i]>max) { s=i; max=fish[i]; } cout<<lake[s][1]*5+time; for(i=2;i<=n;i++) cout<<", "<<lake[s][i]*5; cout<<endl; cout<<"Number of fish expected: "<<fish[s]<<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