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> using namespace std; int main() { __int64 n,i,pre,aft,rpre,raft,min,tempmin,x; __int64 sum,result; scanf("%I64d\n",&n); scanf("%I64d\n",&x); sum=x; min=x; result=x*x; pre=1; aft=1; rpre=1; raft=1; for(i=2;i<=n;i++) { scanf("%I64d",&x); tempmin=x>min?min:x; if(x*x>tempmin*(sum+x)) { pre=i; aft=i; sum=x; min=x; } else { aft++; min=tempmin; sum+=x; } if(sum*min>result) { result=sum*min; rpre=pre; raft=aft; } } printf("%I64d\n%I64d %I64d\n",result,rpre,raft); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator