| ||||||||||
| 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 | |||||||||
哪不对了,测了很多数据 都没查出来,郁闷#include <iostream>
#define MAXN 25
using namespace std;
int n,h;
int F[MAXN+1],D[MAXN+1],T[MAXN],ans[MAXN+1];
int max;
int MAX_Index(int array[],int n);
int main()
{
int i,l,t,j,index,lake;
int tempF[MAXN+1],tempans[MAXN+1],tempmax;
while (cin>>n&&n)
{
cin>>h;
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];
max=0;
for (l=1;l<=n;l++)
{
for (i=1;i<=l;i++) tempF[i]=F[i];
t=h*12;
for (i=1;i<l;i++) t-=T[i];
if (t<=0) break;
memset(tempans,0,sizeof(tempans));
tempmax=0;
for (j=1;j<=t;j++)
{
index=MAX_Index(tempF,l);
if (index==0)
{
for (i=j;i<=t;i++) tempans[1]++;
break;
}
tempans[index]++;
tempmax+=tempF[index];
tempF[index]-=D[index];
}
if (tempmax>max)
{
max=tempmax;
for (i=1;i<=n;i++) ans[i]=tempans[i];
}
}
for (i=1;i<=n;i++)
{
if (i==n) cout<<ans[i]*5<<endl;
else cout<<ans[i]*5<<", ";
}
cout<<"Number of fish expected: "<<max<<endl<<endl;
}
return 0;
}
int MAX_Index(int array[],int n)
{
int i,max=0,index=0;
for (i=1;i<=n;i++)
if (array[i]>max)
{
index=i;
max=array[i];
}
return index;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator