Walledjc @ 2024-09-06 17:47:52
#include <bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int f[10005][10005];
int main(){
int n;
cin>>n;
memset(f,0,sizeof(f));
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
cin>>b[i];
}
for(int i=2;i<=n;i++){
for(int j=2;j<=n;j++){
if(a[i]==b[i]) f[i][j]=f[i-1][j-1]+1;
else f[i][j]=max(f[i-1][j],f[i][j-1]);
}
}
cout<<f[n][n];
return 0;
}
评测记录
by MLE_Automaton @ 2024-09-06 18:04:41
i,j从1起
by MLE_Automaton @ 2024-09-06 18:05:44
@ChenXiJie2013 还有不要memset
by MLE_Automaton @ 2024-09-06 18:06:44
@Walledjc
by JOKER_chu @ 2024-09-06 18:07:37
@Walledjc
改完也是