Pagini recente » Cod sursa (job #1878408) | Cod sursa (job #2867005) | Cod sursa (job #1130341) | Cod sursa (job #2297606) | Cod sursa (job #759909)
Cod sursa(job #759909)
Program Subsir_crescator_maximal; {Complexitate n*log_n}
var a,b,c:array [0..100001] of longint;
i,n,poz,l,max:longint;
fi,fo:text;
procedure cauta(x:longint);
var st,dr,mid:longint;
begin
st:=1; dr:=l; mid:=(st+dr) div 2;
while st<=dr do begin
mid:=(st+dr) div 2;
if c[mid]>x then st:=mid+1
else dr:=mid-1;
end;
poz:=dr;
end;
begin
assign(fi,'scmax.in');
assign(fo,'scmax.out');
reset(fi); rewrite(fo); readln(fi,n);
for i:=1 to n do read(fi,a[i]);
b[n]:=1; c[0]:=1000000; c[1]:=a[n]; l:=1; max:=1;
for i:=n-1 downto 1 do begin
cauta(a[i]);
b[i]:=poz+1;
if poz=l then inc(l);
if c[poz+1]<a[i] then c[poz+1]:=a[i];
if b[i]>max then max:=b[i];
end;
write(fo,max);
close(fo);
end.