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 1079. Maximum

Junyuan Zhang why I get WA(3)????Help me!!!! [2] // Problem 1079. Maximum 8 Jan 2009 08:24
program p1079;
  var
    a:array[0..100000] of longint;
    m:array[1..100000] of longint;
    n,max,i:longint;
  begin
    max:=1;
    a[1]:=1;
    m[1]:=1;
    readln(n);
    while n<>0 do
      begin
        if n<=max then writeln(m[n])
          else
            begin
              for i:=max+1 to n do
                begin
                 if odd(i) then a[i]:=a[i div 2]+a[i div 2+1]
                   else a[i]:=a[i div 2];
                 if a[i]>=m[i-1] then m[i]:=a[i] else m[i]:=m[i-1];
                end;
            end;
        writeln(m[n]);
        readln(n);
      end;
  end.
snow Re: why I get WA(3)????Help me!!!! [1] // Problem 1079. Maximum 22 Sep 2009 23:07
test:
1
2
3
0
right answer is:
1
1
2
Good luck))
Bakhodir Boydedaev Re: why I get WA(3)????Help me!!!! // Problem 1079. Maximum 12 Dec 2014 10:45
Urraaa... Accepted ...!!! Good test.Thank you very much (apple_worm)...!!!