|
|
back to boardwhy WA on test1? Posted by wangyu 3 Oct 2006 18:28 var f:array[0..1100000] of boolean; e,i,n,temp,w,min,q,ans,j,temp1,k:longint; a:integer; begin fillchar(f,sizeof(f),false); f[0]:=true; read(n); temp:=0;temp1:=0; for i:=1 to n do begin read(a); temp1:=temp1+a; for w:=temp downto 0 do if f[w] then f[w+a]:=true; if temp<1000000 then temp:=temp+a; end; min:=maxlongint; e:=temp1 div 2; for j:=0 to temp do if f[j] then begin q:=abs(j-e); if q<min then begin k:=temp1-j; min:=abs(k-j); end; end; writeln(min); end. |
|
|