Pagini recente » Cod sursa (job #2775524) | Cod sursa (job #2901199) | Cod sursa (job #2465360) | Cod sursa (job #1556126) | Cod sursa (job #509359)
Cod sursa(job #509359)
const f='scmax.in';g='scmax.out';
nmax=100001;
var
i,j,poz,n,nr,maxim,k:longint;
v,best,pp,l:array[0..nmax] of longint;
function caut (x:integer):integer;
var
p,u,m:integer;
begin
p:=0;
u:=nr;
m:=(p+u)div 2;
while (p<=u) do
begin
if (v[l[m]]<x) and (v[l[m+1]]>=x) then caut:=m
else if (v[l[m+1]]<x) then
begin
p:=m+1;
m:=(p+u)div 2;
end
else
begin
u:=m-1;
m:=(p+u)div 2;
end;
caut:=nr;
end;
end;
begin
assign(input,f);reset(input);
assign(output,g);rewrite(output);
readln(n);
for i:=1 to n do read(v[i]);
nr:=1;
best[1]:=1;
l[1]:=1;
l[0]:=0;
for i:=2 to n do
begin
poz:=caut(v[i]);
pp[i]:=l[poz];
best[i]:=poz+1;
l[poz+1]:=i;
if (nr<poz+1) then nr:=poz+1;
end;
maxim:=0;poz:=0;
for i:=1 to n do
if (maxim<best[i]) then
begin
maxim:=best[i];
poz:=i;
end;
write(maxim);
writeln;
//afisare(poz);
close(input);close(output);
end.