标签:des style blog io color os for sp 数据
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define N 100005 struct Rect { int x,y; bool operator<(const Rect &t)const { if(x!=t.x) return x<t.x; return y<t.y; } }s[N]; int n; int len; int dp[N]; int up_bound(int k) { int l=1,r=len+1; while(l<r) { int m=(l+r)/2; if(dp[m]<=k) l=m+1; else r=m; }; return l; } void solve() { len=1; dp[1]=s[1].y; for(int i=2;i<=n;i++) { if(s[i].y>=dp[len]) dp[++len]=s[i].y; else { int pos=up_bound(s[i].y); dp[pos]=s[i].y; } } } int main() { while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) { scanf("%d%d",&s[i].x,&s[i].y); } sort(s+1,s+n+1); solve(); printf("%d\n",len); } return 0; }
标签:des style blog io color os for sp 数据
原文地址:http://www.cnblogs.com/hate13/p/4075055.html