【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;
}
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 1101] POI 2007 Zap · 莫比乌斯 & 分块 超详细题解
- 【BZOJ】【P3524】【Poi2014】【Couriers】【题解】【整体二分】
- 【BZOJ】【P1047】【HAOI2007】【理想的正方形】【题解】【单调队列】
- 【BZOJ】【P1046】【HAOI2007】【上升序列】【题解】【dp】
- 【BZOJ】【P2789】【Poi2012】【Letters】【题解】【逆序对】
- 【BZOJ】【P1030】【JSOI2007】【文本生成器】【题解】【AC自动机】
- 【SG函数】BZOJ1188(HNOI2007)[分裂游戏]题解
- BZOJ 1103 POI 2007 大都市meg 树状数组
- [bzoj-1047][HAOI2007]理想的正方形 题解
- 【BZOJ】【P3834】【Poi2014】【Solar Panels】【题解】【分块统计】
- BZOJ 1109: [POI2007]堆积木Klo 神分析, LIS, BIT, 二分
- 【bzoj1614】【Usaco2007 Jan】Telephone Lines架设电话线 (spfa+二分)题解&代码
- Zap [bzoj 1101,POI 2007]
- BZOJ 2096: [Poi2010]Pilots 单调队列题解
- 矩阵乘法专题2——bzoj 1706 [usaco2007 Nov] relays 奶牛接力跑 题解
- 【BZOJ 1046】[HAOI2007]上升序列 lis
- 【BZOJ】【P3831】【Poi2014】【Little Bird】【题解】【单调队列+DP】
- BZOJ 1103 [POI 2007] dfs序+树状数组 解题报告
- 【BZOJ 1130】【POI 2007】大都市meg【树链剖分】
- BZOJ1068:[SCOI2007]压缩——题解