Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
52567 xyh 木板游戏 C++ 运行超时 60 2000 MS 4352 KB 492 2022-07-19 13:07:05

Tests(12/20):


#include<bits/stdc++.h> using namespace std; const int N=5e5+10; int n,c[N],len,dp[N],ans; struct node{ int l,r; }a[N]; bool cmp(node x,node y){ if(x.l==y.l) return x.r>y.r; return x.l<y.l; } int main(){ scanf("%d",&n); for(register int i=1;i<=n;i++){ scanf("%d%d",&a[i].l,&a[i].r); } sort(a+1,a+1+n,cmp); for(int i=n;i>=1;i--){ dp[i]=1; for(int j=i+1;j<=n;j++) if(a[j].r<=a[i].r) dp[i]=max(dp[i],dp[j]+1); ans=max(ans,dp[i]); } cout<<ans<<endl; }


测评信息: