include[HTML_REMOVED]
using namespace std;
const int N = 3010;
int n, ans;
int a[N], b[N];
int f[N][N];
int main()
{
cin >> n;
for (int i = 1; i <= n; i)
cin >> a[i];
for (int i = 1; i <= n; i)
cin >> b[i];
for (int i = 1; i <= n; i)
{
int maxn = 1;
for (int j = 1; j <= n; j )
{
f[i][j] = f[i - 1][j];
if (a[i] == b[j]) f[i][j] = max(f[i][j], maxn);
if (a[i] > b[j]) maxn = max(maxn, f[i - 1][j] + 1);
}
}
for (int i = 1; i <= n; i ++ ) ans = max(ans, f[n][i]);
cout << ans << endl;
return 0;
}
$MarkDown$
蟹蟹