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

刘洋大傻逼看这里~~~

Posted by 994070074 at 2015-07-30 17:23:02 on Problem 2796
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:
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