Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

相同0的数据及其他很多数据我都试了,可就是wa啊!!这是怎么个请况,哪位大哥大姐帮忙看一下

Posted by liudunxu at 2009-09-09 20:49:33 on Problem 1042
#include <iostream>
#include<stdlib.h>
using namespace std;
int LakeNum;
int TimePossess;
int t2;
int T;
int thesum;
int eveyLakeTime[30][30];
int startNum[30]={0};
int saveNum[30]={0};
int decNum[30]={0};
int roadTime[30]={0};
int sumTime[30]={0};
int total1;
int memTime;
int Maxtotal;

int findMax(int num[],int n)
{
  	
int currentMax=0;
   int zz=0;
   for(int i=0;i<n;i++)
   {
	   if(num[i]>currentMax) {currentMax=num[i];zz=i;}
   }
   return zz;
   
}
int main()
{
  thesum=0;
memTime=0;	
total1=0;
Maxtotal=0;
  int arraynum;
  
	while(cin>>LakeNum&&LakeNum!=0)
   {
	   cin>>TimePossess;
	   t2=TimePossess*60;
	   T=t2;
	   for(int i=0;i<LakeNum;i++)
	   {
		   cin>>startNum[i];
		  
	   }
	   for(int pp=0;pp<LakeNum;pp++)
		   cin>>decNum[pp];
	   for(int j=1;j<LakeNum;j++)
	   {
		   cin>>roadTime[j];
	   roadTime[j]*=5;
	   }
	   sumTime[0]=0;
	   sumTime[1]=roadTime[1];
	   for(int k=2;k<LakeNum;k++)
		   sumTime[k]=sumTime[k-1]+roadTime[k];
     for(int jj=0;jj<LakeNum;jj++) saveNum[jj]=startNum[jj];
	   for(int aa=0;aa<LakeNum;aa++)
	   {
            t2-=sumTime[aa];
			while(t2>0)
			{
              arraynum=findMax(startNum,aa+1);
			  //cout<<startNum[arraynum]<<endl;
			  if(startNum[arraynum]>=0)
			  {total1=total1+startNum[arraynum];eveyLakeTime[arraynum][aa]+=5;t2=t2-5;}
			  else if(startNum[arraynum]<0) break;

			  
			  startNum[arraynum]-=decNum[arraynum];
               
             

			}
			if(total1>Maxtotal) {Maxtotal=total1;memTime=aa;}
			total1=0;
             t2=T;    
			for(int ii=0;ii<LakeNum;ii++) startNum[ii]=saveNum[ii];

	   }
    
	       
	   
thesum=0;
t2=T;

for(int oo=0;oo<LakeNum;oo++) thesum+=eveyLakeTime[oo][memTime];
t2-=sumTime[memTime];
if(thesum<t2) eveyLakeTime[0][memTime]=eveyLakeTime[0][memTime]+t2-thesum;
for(int zz=0;zz<LakeNum-1;zz++) cout<<eveyLakeTime[zz][memTime]<<", ";
cout<<eveyLakeTime[LakeNum-1][memTime]<<endl;
cout<<"Number of fish expected: "<<Maxtotal<<endl<<endl;

Maxtotal=0;
memset(eveyLakeTime,0,sizeof(eveyLakeTime));
   }
 return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator