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

无奈啊。。为何总是WA~~哪位高人指点一下啊~谢谢啦

Posted by ray58750034 at 2005-09-19 11:35:16 on Problem 1701
#include <iostream>
using namespace std;

int main(){
	long t[10000];
	long long u[10000];
	long long d[10000];
	long long sum,k;
	
	int c,n,f,i,j,a,b;
	scanf("%d",&c);
	while(c-->0){
		scanf("%d %d %d",&n,&a,&b);
		
		k=sum=0;
		for(i=0;i<n;i++){
			scanf("%d",&t[i]);
			if(i==0)u[i]=0;
			else {
				u[i]=u[i-1]+sum*a+k;
			}
			k+=sum;
			sum+=t[i];
		}
		
		k=sum=0;
		for(i=0;i<n;i++){
			if(i==0)d[n-1-i]=0;
			else{
				d[n-1-i]=d[n-i]+sum*b+k;
			}
			k+=sum;
			sum+=t[n-1-i];
		}
		
		sum=d[0];
		f=0;
		for(i=1;i<n;i++){
			k=u[i]+d[i];
			if(sum>=k){
				sum=k;
				f=i;
			}
		}
		
		/*for(i=0;i<n;i++){
			cout<<u[i]<<" "<<d[i]<<endl;
		}*/
		printf("%d\n",f+1);
	}
}

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