|
|
вернуться в форум1005 Послано olzii 18 мар 2007 14:21 what's wrong??? i get 'wrong answer' help var c,a:array[1..1000] of integer; u,h,p,y,t,k,j,i,n:integer; min:longint; begin assign(input,'sto.in');reset(input); assign(output,'sto.out');rewrite(output); readln(n); k:=1; min:=1000000; for i:=1 to n do begin readln(a[i]); k:=k*2; end; repeat inc(i); begin p:=i; for j:=1 to n do begin c[j]:=p mod 2; p:=p div 2; end; y:=0; t:=0; for j:=1 to n do begin if c[j]=0 then y:=y+a[j]; if c[j]=1 then t:=t+a[j]; end; u:=abs(y-t); if min>u then min:=u; end; until i=k; write(min); close(input);close(output); end. Edited by author 18.03.2007 14:22 |
|
|