DÃY CON LỒICONST FIN=’DAYLOI.INP’; PROCEDURE DOWN; BEGIN VAR I...

Bài 1 - Dãy con lồi

const fin=’DAYLOI.INP’;

Procedure Down;

begin

var i,j :integer;

assign(f,fou);

fou=’DAYLOI.OUT’;

nmax=2000;

rewrite(f);

type arr= Array[0..nmax+1] of

for i:=n downto 1 do

writeln(f,KyLuc);

integer;

for j:=n downto i+1 do

if KyLuc >0 then

var

if (A[i]

GhiLen(ViTri);

A: arr;

GhiXuong(TrD[ViTri]);

D[i]:=D[j]+1;

U,Tru,D,TrD: arr; {Up, Down}

end;

n, KyLuc, Vitri: integer;

TrD[i]:=j;

f: text;

close(f);

procedure Nhap;

procedure ChuanBi;

procedure TimDiemGay;

var i: integer;

for i:=1 to n do

assign(f,fin);

KyLuc:=0;

reset(f);

readln(f,n);

U[i]:=1;

D[i]:=1;

if (U[i]>1) and (D[i]>1) and (U[i]

for i:=1 to n do read(f,A[i]);

TrU[i]:=0;

+D[i]-1>KyLuc) then

TrD[i]:=0;

procedure GhiLen(i: integer);

KyLuc:=U[i]+D[i]-1;

Vitri:=i;

procedure Up;

if TrU[i]<>0 then GhiLen(TrU[i]);

var i,j: integer;

Write(f,A[i],’ ’);

BEGIN

Nhap;

procedure GhiXuong(i: integer);

for j:=1 to i-1 do

ChuanBi;

if (A[i]then

Up;

Down;

if TrD[i]<>0 then

TimDiemGay;

U[i]:=U[j]+1;

GhiXuong(TrD[i]);

Xuat;

TrU[i]:=j;

END

procedure Xuat;