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

why I get WA(3)????Help me!!!!
Posted by zhl 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.
Re: why I get WA(3)????Help me!!!!
Posted by apple_worm 22 Sep 2009 23:07
test:
1
2
3
0
right answer is:
1
1
2
Good luck))
Re: why I get WA(3)????Help me!!!!
Posted by Bahodir | TUIT | 12 Dec 2014 10:45
Urraaa... Accepted ...!!! Good test.Thank you very much (apple_worm)...!!!