|
|
back to boardWA on test №1. Where is mistake in my program? program Project1; var a:array [1..20] of integer; n,i:byte; suma:integer; suma1,sumaTemp:integer; procedure rekurs(k:byte); var i:byte; begin for I:=k to n do begin dec(sumaTemp,a[i]); if sumaTemp>=0 then if sumaTemp=0 then begin writeln(suma-suma1*2); halt(13) end else rekurs(i+1); inc(sumaTemp,a[i]); end; end; begin suma:=0; readln(n); for i:=1 to n do begin readln(a[i]); inc(suma,a[i]); end; if n=1 then writeln(suma) else begin suma1:=suma div 2; while suma1>0 do begin sumaTemp:=suma1; rekurs(1); dec(suma1); end; end; end. |
|
|