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

Common Board

Help!! CLICK ME!!!
Posted by Manolache Adrian 21 May 2004 18:44
Why do i get WA ???
Give me a test, that won't work on my program
Problem: Stone pile
Check it out
{wrong answer}
var min,n,sum1,sum2:longint;
    W,stone:array[1..20] of longint;

    procedure read;
    var i:integer;
    begin
      readln(n);
      for i:=1 to n do
        readln(W[i]);
      sum1:=0; sum2:=0; min:=maxlongint;
    end;

    procedure solve(p:longint);
    var i:longint;
    begin
      if p>n then begin
        if abs(sum1-sum2)<min then
          min:=abs(sum1-sum2);
      end else begin
        for i:=1 to 2 do begin
          stone[p]:=i;
          if i=1 then inc(sum1, W[p]);
          if i=2 then inc(sum2, W[p]);

          solve(p+1);

          if i=1 then dec(sum1, W[p]);
          if i=2 then dec(sum2, W[p]);
        end;
      end;
    end;

begin
  read;
  solve(1);
  writeln(min);
end.
Use read instead readln
Posted by A new start... 22 May 2004 17:56
Re: Use read instead readln
Posted by Manolache Adrian 27 May 2004 21:42
thank's! that worked!