求hack数据
  • 板块灌水区
  • 楼主wuming_z
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/27 14:16
  • 上次更新2025/1/27 14:17:27
查看原帖
求hack数据
1125000
wuming_z楼主2025/1/27 14:16

运用Dilworth定理求最长上升子序列个数有什么问题吗
【题目传送门】

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n;
int mp[1000001];
int ge[1000001];

signed main() {
	memset(ge, 0x3f, sizeof ge);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> mp[i];
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		int w = upper_bound(ge + 1, ge + ans + 1, mp[i],greater<int>()) - ge;
		ge[w] = mp[i];
		ans = max(ans, w);
	}
	cout << ans;
	return 0;
}
2025/1/27 14:16
加载中...