二分优化的
var a:array[1..100]of longint;
b:array[1..100]of longint;
i,n,s,h:longint;
procedure erfen(x,y:longint);
var w:longint;
begin
if x>=y then
begin
h:=x;
exit;
end;
w:=(x+y) div 2;
if ((b[w]<=a[i]) and (b[w+1]>=a[i])) then
begin
h:=w+1;
exit;
end
else
if b[w+1]<=a[i] then
erfen(w+1,y)
else
if b[w]>=a[i] then
erfen(x,w);
end;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
b[1]:=a[1];
s:=1;
for i:=2 to n do
begin
if a[i]>=b[s] then
begin
s:=s+1;
b[s]:=a[i];
end
else
begin
erfen(1,s);
b[h]:=a[i];
end;
end;
writeln(s);
end.
var a:array[1..100]of longint;
b:array[1..100]of longint;
i,n,s,h:longint;
procedure erfen(x,y:longint);
var w:longint;
begin
if x>=y then
begin
h:=x;
exit;
end;
w:=(x+y) div 2;
if ((b[w]<=a[i]) and (b[w+1]>=a[i])) then
begin
h:=w+1;
exit;
end
else
if b[w+1]<=a[i] then
erfen(w+1,y)
else
if b[w]>=a[i] then
erfen(x,w);
end;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
b[1]:=a[1];
s:=1;
for i:=2 to n do
begin
if a[i]>=b[s] then
begin
s:=s+1;
b[s]:=a[i];
end
else
begin
erfen(1,s);
b[h]:=a[i];
end;
end;
writeln(s);
end.