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 1005. Stone Pile

why WA? HELP ME!
Posted by Khosrow 25 Jun 2007 01:53
here is my program; tell me what's wrong with it.plz.
program khosrow;
var
c,i,j,h,n,sum,sub:integer;
a,w:array[1..20]of integer;
begin
read(n);
sum:=0;
for i:=1 to n do
    begin
        readln(w[i]);
        sum:=sum+w[i];
    end;
c:=sum;
for i:=1 to n do
    a[i]:=0;
repeat
i:=0;
      repeat
            inc(i);
      until a[i]=0;
      a[i]:=1;
      for j:=1 to i-1 do
          a[j]:=0;
      sub:=0;
      for h:=1 to n do
          if a[h]=1 then sub:=sub+w[h];
      if c>abs(sum-(2*sub)) then
         c:=abs(sum-(2*sub));
until sub=sum;
writeln(c);
end.