|
|
вернуться в форумWhy does not pass the first test???? (1005) program perebor; var a,b:array[1..20] of longint; i,n,otv:longint; procedure profi(sum1:longint); var j,sum2,ff:longint; begin sum2:=0; if i<=n then begin for j:=1 to n do if a[j]<>0 then sum2:=sum2+a[j]; if sum2>sum1 then ff:=sum2-sum1 else ff:=sum1-sum2; if ff<otv then otv:=ff; for j:=1 to n do if a[j]<>0 then begin i:=i+1; sum1:=sum1+a[j]; a[j]:=0; profi(sum1); sum1:=sum1-b[j]; a[j]:=b[j]; i:=i-1; end; end; end; begin otv:=maxlongint; readln(n); for i:=1 to n do begin readln(a[i]); b[i]:=a[i]; end; i:=0; profi(0); write(otv); end. Edited by author 27.03.2005 00:58 |
|
|