您的位置:首页 > 其它

【BZOJ】【P1109】【POI2007】【堆积木Klo】【题解】【LIS】

2014-10-03 15:10 281 查看
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1109

Seter是厉害http://seter.is-programmer.com/posts/32037.html

Code:

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
pair<int,int> a[maxn];
int d[maxn];
int s,n,size;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[++s].second);
if(a[s].second>i)s--;
else{
a[s].first=i-a[s].second;
}
}
sort(a+1,a+1+s);
for(int i=1;i<=s;i++){
int j=lower_bound(d,d+size,a[i].second)-d;
d[j]=a[i].second;
size=max(size,j+1);
}cout<<size<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  bzoj