捆绑re求助
查看原帖
捆绑re求助
518761
yunzi_AKIOI楼主2021/12/22 17:48
#include<bits/stdc++.h>
#define maxn 50050
using namespace std;
int f[maxn],a[maxn],b[maxn];
struct edge{
	int begin;
	int end;
}e[maxn];
bool cmp(edge a,edge b)
{
	return a.begin<b.begin;
}
int main()
{
	int n;
	int ans=-1;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>e[i].begin>>e[i].end;
	}
	sort(e+1,e+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		f[i]=1;
		for(int j=1;j<i;j++)
		{
			if(e[i].end>=e[j].end&&f[i]<f[j]+1)
			{
				f[i]=f[j]+1;
			}
		}
		ans=max(ans,f[i]);
	}
	cout<<ans;
}
2021/12/22 17:48
加载中...