hoj 13969 Racing Gems

//最长非降子序列 感觉思维还是有点僵化哦 
#include <iostream> #include <algorithm> #include <stdio.h> #include <set> #include <queue> #include <cstring> #include <string> #include <limits.h> #include <string.h> #include <vector> #include <map> #define LL long long #define INF 2100000000 #define fi first #define se second #define lowbit(x) (x&(-x)) #define eps 5e-7 using namespace std; const int maxn=(int)1e5 +10; const int maxm=(int)2e4+10; const LL MOD=(LL)1e9+7; int n;LL r,w,h; LL a,b; struct nod{ LL x,y; void in(){ scanf("%I64d%I64d",&a,&b); x=b-r*a;y=b-r*(w-a); } }; bool cmp(const nod&a,const nod&b){ return (a.y==b.y&&a.x<b.x )||a.y<b.y; } nod f[maxn]; vector<LL> q; int main() { #ifdef shuaishuai freopen("C:\\Users\\hasee\\Desktop\\a.txt","r",stdin); //freopen("C:\\Users\\hasee\\Desktop\\b.txt","w",stdout); #endif scanf("%d%I64d%I64d%I64d",&n,&r,&w,&h); for(int i=0;i<n;i++) f[i].in(); sort(f,f+n,cmp); q.reserve(n); q.push_back(f[0].x); for(int i=1;i<n;i++){ if(q.back()<=f[i].x) q.push_back(f[i].x); else *upper_bound(q.begin(),q.end(),f[i].x)=f[i].x; } printf("%d\n",q.size()); return 0; }

 

posted @ 2017-09-05 17:16  MeowMeowMeow  阅读(163)  评论(0编辑  收藏  举报