Kaiser_Weltreich @ 2021-08-21 14:36:33
二十分,对了前俩点,其他全WA
#include<bits/stdc++.h>
//#include<Weltreich.h>
using namespace std;
int len = 0;
#define MAXN 100005
int alig[MAXN], edt[MAXN], man[MAXN];
int n;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> alig[i];
for (int i = 1; i <= n; i++) {
int m;
cin >> m;
edt[m] = i;
}
for (int i = 1; i <= n; i++) {
if (edt[man[len]] <= edt[alig[i]] ) {
man[len + 1] = alig[i];
len++;
} else {
man[lower_bound(edt + 1, edt + 1 + len, alig[i], greater < int > ()) - edt] = alig[i];
}
}
cout << len << endl;
return 0;
}
蒟蒻再弱弱地问一句,如果两个序列长度不一样怎么办?