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 |
无奈啊。。为何总是WA~~哪位高人指点一下啊~谢谢啦#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator