提交时间:2022-07-19 13:49:12
运行 ID: 52601
#include <iostream> #include <algorithm> using namespace std; int n; struct muban{ int l,r; }a[25]; bool cmp(muban x,muban y){ return x.l<y.l; } int ans=0; bool u[25]; int haha(int x){ int p=0; for(int i=1;i<=n;i++){ if(u[i]==0){ if(a[i].l>=a[x].l && a[i].r<=a[x].r){ u[i]=1; p=max(p,haha(i)); u[i]=0; } } } return p+1; } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].l>>a[i].r; } int ans=0; for(int i=1;i<=n;i++){ u[i]=1; ans=max(ans,haha(i)); u[i]=0; } cout<<ans<<endl; return 0; }