#include<iostream>usingnamespace std;constint N =110000;int f[N], n, len;intmain(){
cin >> n;for(int i =1; i <= n; i++){int x;
cin >> x;int l =0, r = len;while(l < r){int mid = l + r +1>>1;if(x > f[mid])l = mid;else r = mid -1;}
len =max(len, l +1);
f[l +1]= x;}
cout << len;return0;}
#include<iostream>usingnamespace std;constint N =1100;int f[N][N], n, m;
string a, b;intmain(){
cin >> n >> m >> a >> b;
a =' '+ a, b =' '+ b;for(int i =1; i <= n; i++)for(int j =1; j <= m; j++)
f[i][j]=max(f[i -1][j -1]+(a[i]== b[j]),max(f[i -1][j], f[i][j -1]));
cout << f[n][m];return0;}
#include<iostream>#include<cstring>usingnamespace std;constint N =1100;int n, m, f[N][N];
string a, b;intmain(){
cin >> n >> a >> m >> b;
a =' '+ a, b =' '+ b;memset(f,0x3f,sizeof f);for(int i =0; i <= n; i++)f[i][0]= i;for(int i =0; i <= m; i++)f[0][i]= i;for(int i =1; i <= n; i++)for(int j =1; j <= m; j++)
f[i][j]=min(f[i -1][j -1]+-(a[i]== b[j]),min(f[i -1][j], f[i][j -1]))+1;
cout << f[n][m];return0;}