|
|
вернуться в форумОбщий форумHelp!! CLICK ME!!! 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. Re: Use read instead readln thank's! that worked! |
|
|