最长不下降子序列
include<bits/stdc++.h>
using namespace std;
int n,a[100009],d[100009],f[100009],ans;
int main()
{
cin >> n;
for (int i = 1;i <= n;i++)
{
cin >> a[i];
d[i] = 1000000;
}
for (int i = 1;i <= n;i++)
{
int now = upper_bound(d+1,d+n+1,a[i])-d;
f[i] = now;
d[now] = a[i];
ans = max(ans,f[i]);
}
cout << ans ;
return 0;
}