LCIS的程序出了点问题
  • 板块学术版
  • 楼主pencil
  • 当前回复0
  • 已保存回复0
  • 发布时间2021/8/13 16:49
  • 上次更新2023/11/4 10:47:47
查看原帖
LCIS的程序出了点问题
137723
pencil楼主2021/8/13 16:49
#include<bits/stdc++.h>
using namespace std;
int n,f[666][666],a[666],b[666];
int main() {
	int i,m,j,k;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
//	cin>>m;
	m=n;
	for(i=1;i<=m;i++)
	cin>>b[i];int s=0;
	for(i=1;i<=n;i++){
		
		for(j=1;j<=m;j++){
			f[i][j]=f[i-1][j];
			int l=j-1;
			if(b[l]<a[i])
			s=max(s,f[i-1][l]+1);
			if(a[i]==b[j])
			f[i][j]=max(f[i][j],s);
			
		}
	}
	cout<<s;
	return 0;
}
输入
10
1 5 3 6 3 2 7 3 6 2 
9 6 2 3 1 5 3 3 6 1
应输出3
我的输出5
2021/8/13 16:49
加载中...