P1233 木棍加工

//#define local
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#define MAXN 5005
using namespace std;
typedef long long ll;
struct size{
	int l,w;
	size(int l=0,int w=0):l(l),w(w){
		
	}
	bool operator < (const size &t) const{
	if(l!=t.l)
	return l>t.l;
	else
	return w>=t.w;
	}
}; 
vector<size>g;//n(不严格下降极大子序列)=l(最长严格上升序列 ) 
int n;

int main(){
#ifdef local
freopen("data.in","rb",stdin);
//freopen("data.out","wb",stdout);
#endif
scanf("%d",&n);
for(int i=0;i<n;++i){
	int ll,ww;
	scanf("%d%d",&ll,&ww);
	g.push_back(size(ll,ww));
}
sort(g.begin(),g.end());
vector<int>d;
d.push_back(g[0].w);
for(int i=1;i<n;++i){
	int next=g[i].w;
	if(next>d.back())
	d.push_back(next);
	else{
		vector<int>::iterator it=lower_bound(d.begin(),d.end(),next);
		d[it-d.begin()]=next;
	}
}

cout<<d.size();

return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值