|
|
back to boardwhy it is wrong???????????? var a,b:array [1..101] of longint; k:longint; procedure init; var i:longint; begin fillchar(a,sizeof(a),0); readln(k); for i:=1 to k do read(a[i]); end; procedure work; var k1,t,max,i,j,min,jl:longint; begin k1:=0; max:=0; min:=a[1]; k1:=trunc(k/2)+1; for i:=1 to k-1 do for j:=1 to k-1 do begin if min>a[j+1] then begin min:=a[j+1]; jl:=j+1; end; if j=k-1 then begin b[i]:=min; a[jl]:=10002; min:=a[i]; end; end; for i:=1 to k1 do max:=max+(trunc(b[i]/2)+1); writeln(max); end; begin init; work; end. Re: why it is wrong???????????? try test: 6 1 5 9 3 7 11 answer: 10 Why you not sort array??? Re: why it is wrong???????????? Sory? but my test is incorrect... try this test 5 3 5 7 9 11 answer: 9 |
|
|