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的

Posted by mathzqy at 2004-07-11 11:59:55 on Problem 1042
In Reply To:help me!! Posted by:yipeng at 2004-07-10 19:16:33
> 为什么wa
> #include "stdio.h"
> void main(){
> 	long i,j,n,h,sum,max,max1,k1,time;
> 	long fi[50],di[50],ti[50],s[50];
> 	long f[50],d[50],hi[50],hs[50];
> 	while(scanf("%ld",&n)!=EOF){
>         if(n==0)
> 			break;
> 		scanf("%ld",&h);
> 		h=h*60;
> 		for(i=1;i<=n;i++)
> 			scanf("%ld",&fi[i]);
> 		for(i=1;i<=n;i++)
> 			scanf("%ld",&di[i]);
> 		for(i=1;i<n;i++){
> 			scanf("%ld",&ti[i]);
> 			ti[i]=5*ti[i];
> 		}
>         s[0]=s[1]=0;
> 		for(i=2;i<=n;i++){
> 			s[i]=s[i-1]+ti[i-1];
> 		}
> 		max=0;
> 		for(i=1;i<=n;i++){
> 			time=h-s[i];
> 			for(j=1;j<=n;j++){
> 				f[j]=fi[j];
> 				d[j]=di[j];
> 				hi[j]=0;
> 			}
> 			sum=0;
> 			while(time>=5){
> 				time=time-5;
> 				max1=-1;k1=1;
>                 for(j=1;j<=i;j++){
> 					if(f[j]>max1){
> 						max1=f[j];
> 						k1=j;
> 					}
> 				}
> 				for(j=1;j<=i;j++){
> 					if(f[j]==max1){
> 						k1=j;
> 						break;
> 					}
> 				}
> 				if(f[k1]>0){
> 					sum=sum+f[k1];
> 				    f[k1]=f[k1]-d[k1];
> 					if(f[k1]<0)
> 						f[k1]=0;
> 					hi[k1]=hi[k1]+5;
> 				}
> 				else{
> 					hi[k1]=hi[k1]+5;
> 				}	
> 			}
> 			if(sum>max){
> 				max=sum;
> 				for(j=1;j<=n;j++){
> 					hs[j]=hi[j];
> 				}
> 			}
> 		}
> 		for(i=1;i<=n;i++){
> 		    printf("%ld",hs[i]);
> 			if(i<n)
> 				printf(", ");
> 		}
> 		printf("\n");
> 		printf("Number of fish expected: %ld\n",max);
> 		printf("\n");
> 	}
> }

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