ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1296. Hyperjump

I have TLE... Help...
Posted by Neo Nomaly 12 Apr 2005 12:11
This is finding maxinmum sum in p array... I have TLE on test #13... Help...

procedure solve;
var
  i,j:longint;
begin
  a[1]:=p[1];
  max:=a[1];
  for i:=2 to n do begin
    a[i]:=p[i]+a[i-1];
    if max<a[i] then max:=a[i];
  end;
  for i:=1 to n do
    for j:=i to n do
      if max<a[j]-a[i]+p[i] then max:=a[j]-a[i]+p[i];
end;
Re: I have TLE... Help...
Posted by Cybernetics Team 12 Apr 2005 17:10
This can be done in O(N), yours is O(N²)