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 |
刘洋大傻逼看这里~~~var a,s:array[0..100005] of int64; l,r:array[0..100005] of longint; i,n,ll,rr:longint; ans,max:int64; begin readln(n); s[0]:=0; ans:=-1; max:=-1; for i:=1 to n do begin read(a[i]); l[i]:=i; r[i]:=i; s[i]:=s[i-1]+a[i]; end; for i:=1 to n do while (l[i]>1) and (a[l[i]-1]>=a[i]) do l[i]:=l[l[i]-1]; for i:=n downto 1 do while (r[i]<n) and (a[r[i]+1]>=a[i]) do r[i]:=r[r[i]+1]; for i:=1 to n do begin ans:=(s[r[i]]-s[l[i]-1])*a[i]; if max<=ans then begin max:=ans; ll:=l[i]; rr:=r[i]; end; end; writeln(max); writeln(ll,' ',rr); end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator