#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct hp{ int ai,bi,ci; }a[1005]; bool cmp(hp a,hp b){ return a.bi<b.bi; } const int M =1e6+2; int n,i,j,k,maxn,f[1005]; int c[M]; int lowbit(int x){ return x&-x;} void add(int x,int v){ for(;x<=1e6;x+=lowbit(x)) c[x]=max(c[x],v); } int qq(int x){ int t=0; for(;x;x-=lowbit(x)) t=max(t,c[x]); return t; } signed main(){ scanf("%d",&n); for (i=1;i<=n;++i) scanf("%d%d%d",&a[i].ai,&a[i].bi,&a[i].ci); sort(a+1,a+n+1,cmp); int ans=0; for (i=2;i<=n;++i){ f[i]=a[i].ci; f[i]=max(f[i],qq(a[i].ai)) ; add(a[i].ai,f[i]) ; ans=max(ans,f[i]) ; } cout<< ans <<endl; }
标签:覆盖,线段,bi,codevs3012,include,hp From: https://www.cnblogs.com/towboa/p/17573075.html