标签:cout 树状数组 bool bsp include cin com upd algorithm
#include<iostream> #include<algorithm> #define maxn 100000 #define lb(x) x&-x using namespace std; int f[maxn],n,m,k,tot; struct st{ int a,b; }s[maxn]; void update(int x,int val) { while(x<maxn) { f[x]=max(f[x],val); x+=lb(x); } } int sum(int x) { int ans=0; while(x) { ans=max(ans,f[x]); x-=lb(x); } return ans; } bool com(st x,st y) { return x.a<y.a; } main(){ cin>>n; for(int i=1;i<=n;i++) cin>>s[i].a>>s[i].b; sort(s+1,s+1+n,com); for(int i=1;i<=n;i++) { k=sum(s[i].b); update(s[i].b,k+1); tot=max(tot,k+1); } cout<<tot; }
标签:cout 树状数组 bool bsp include cin com upd algorithm
原文地址:http://www.cnblogs.com/kczno1fans/p/7497524.html