Bài 81/2001 - Dãy nghịch thế
(Dành cho học sinh PTTH)
Program day_nghich_the;
uses crt;
const fn = 'nghich.inp';
gn = 'nghich.out';
nmax=10000;
var f,g:text;
n,i,j,dem:0..nmax;
a,b,luu:array[1..nmax] of 0..nmax;
procedure nhap;
begin
fillchar(a,sizeof(a),0); b:=a;
assign(f,fn); reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]); write(f);
for i:=1 to n do read(f,b[i]);
close(f);
end;
procedure tim_b;
fillchar(luu,sizeof(luu),0);
for i:=1 to n do
begin
dem:=0;
for j:=i -1 downto 1 do
if a[i]<a[j] then inc(dem);
luu[a[i]]:=dem;
end;
for i:=1 to n do write(g,luu[i]:2);
writeln(g); writeln(g);
end;
procedure tim_a;
if b[i]>n-i then exit else
j:=0;
repeat
inc(dem);
if luu[dem]=0 then j:=j+1;
until j>b[i];
luu[dem]:=i;
for i:=1 to n do write(g,luu[i]:2);
BEGIN
nhap;
assign(g,gn);rewrite(g);
tim_b;
tim_a;
close(g);
END.
kk:=1 to (best-l[mx,my,k]) div 2 do write(f,lap);
Bạn đang xem bài 81/ - 100 DE TIN HSG CO DAP AN