|
|
вернуться в форумwa7 I've tried all the tests mentioned here, and the output was correct. Still I have WA on test 7 var a,b,c,d: array [1..102] of integer; ind,n,i,j,k,z,v:integer; begin readln(n); k:=0; z:=0; for i:=1 to n do begin read(a[i]); readln(b[i]); if a[i]>b[i] then begin inc(z); d[i]:=1; end else d[i]:=0; end; if z>n div 2 then for j:=1 to n-1 do for i:=1 to n-1 do if d[i]>d[i+1] then begin v:=d[i]; d[i]:=d[i+1]; d[i+1]:=v; v:=a[i]; a[i]:=a[i+1]; a[i+1]:=v; v:=b[i]; b[i]:=b[i+1]; b[i+1]:=v; end; if z<n div 2 then for j:=1 to n-1 do for i:=1 to n-1 do if d[i]<d[i+1] then begin v:=d[i]; d[i]:=d[i+1]; d[i+1]:=v; v:=a[i]; a[i]:=a[i+1]; a[i+1]:=v; v:=b[i]; b[i]:=b[i+1]; b[i+1]:=v; end; repeat for i:=1 to n do c[i]:=0; for i:=1 to n do for j:=1 to n do if (((a[i]>a[j]) and (b[i]<b[j])) or ((a[i]<a[j]) and (b[i]>b[j]))) then c[i]:=c[i]+1; ind:=1; for i:=2 to n do if c[i]>c[ind] then ind:=i; a[ind]:=0; b[ind]:=0; if (c[ind]>0) then k:=k+1; until c[ind]=0; writeln(k); readln; end. |
|
|