chenshixue @ 2023-12-30 10:03:16
代码献上,数组范围一开大就MLE
救救me
#include <bits/stdc++.h>
using namespace std;
int n,a1[10100],a2[10010];
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a1[i];
}
for(int i=1;i<=n;i++){
cin>>a2[i];
}
int f[1010][1010]={0};
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
f[i][j]=f[i-1][j-1];
if(a1[i]==a2[j]){
f[i][j]=f[i-1][j-1]+1;
}
f[i][j]=max(f[i][j],f[i-1][j]);
f[i][j]=max(f[i][j],f[i][j-1]);
}
}
cout<<f[n][n];
return 0;
}
by chenshixue @ 2023-12-30 10:06:25
错误真迹
数组范围开大后
by heyx0201 @ 2023-12-30 10:18:17
@chenshixue 你这个玩意就是针对
by I_will_AKIOI @ 2023-12-30 10:39:42
f数组放外面
by I_will_AKIOI @ 2023-12-30 10:40:18
srds,放外面后不会re,会tle