30pts 求救助!
查看原帖
30pts 求救助!
1308563
封禁用户楼主2024/8/1 09:44
#include<bits/stdc++.h>
#define LL long long

using namespace std;
const int N = 2e5 + 5;
int n;
struct node{
	int n,w;
}a[N];
bool cmp(node a,node b){
	return a.n < b.n;
}
int list_[N],ans;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cin >> n;
	for(int i = 1;i <= n;++i){
		cin >> a[i].n >> a[i].w;
	}
	sort(a + 1,a + n + 1,cmp);
	for(int i = 2;i <= n;++i){
		if(a[i].w > list_[ans]){
			ans ++;
			list_[ans] = a[i].w;
		}
		else{
			*lower_bound(list_ + 1,list_ + ans + 1,a[i].w) = (a[i].w);
		}
	}
	cout << ans;
	return 0;
}
2024/8/1 09:44
加载中...