样例都过不了,玄关求助
查看原帖
样例都过不了,玄关求助
999658
talkwithc楼主2024/9/15 16:08

代码仅解决第一问

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

const int xx = 100010;
const int INF = 0x7ffffff;

int n, m[xx], ans = -1, f[xx], a[xx];
int main()
{
	while (cin >> (m[++n]));
	//--n;

	memset(a, 0x3f, sizeof(a));
	for (int i = 1; i <= n; ++i)
	{
		int j = lower_bound(a, a + n, m[i]) - a;
		f[i] = j + 1;
		ans = max(ans, f[i]);
		a[f[i]] = m[i];
	}
	cout << ans;
	return 0;
}
2024/9/15 16:08
加载中...