const fin='DOIDAU.inp'; fon='DOIDAU.out'; vc=10000; nmax = 100005; var a:array[0..nmax] of longint; f,g,t:array[0..nmax] of longint; n,i,l,u,res:longint; procedure nhap; begin read(n,L,U); for i:=1 to n do read(a[i]); end; procedure xuli; var i,j,max,imax,d:longint; kq:array[1..nmax] of longint; begin f[1]:=1;g[1]:=1; for i:=2 to n do begin max:=0; for j:=1 to i-1 do if (i-j>=L) and (a[i]>a[j]) and (a[i]-a[j]<=U) and (g[j]>max) then max:=g[j]; f[i]:=max+1; max:=0; for j:=1 to i-1 do if (i-j>=L) and (a[i]<a[j]) and (a[j]-a[i]<=U) and (f[j]>max) then max:=f[j]; g[i]:=max+1; end; res:=0; for i:=1 to n do begin if f[i]>res then res:=f[i]; if g[i]>res then res:=g[i]; end; writeln(res); end; begin assign(input,fin);reset(input); assign(output,fon);rewrite(output); nhap; xuli; close(input);close(output); end.
* Chuyên dạy lập trình ONLINE cho học sinh THCS, THPT *.
Mọi giao lưu, trao đổi, xin liên hệ: Lê Quang Vinh - zalo: 037.803.8755.
Page: Lớp học Code Sky
Group FB1: Ôn thi HSG9 - THTB - TS10 chuyên tin
Group FB2: Học Scratch - Ôn thi Tin học trẻ bảng A
Thứ Ba, 3 tháng 5, 2022
DOIDAU PASCAL
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét
Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.