UVA 10534 Wavio Sequence(LIS O(nlogn))
来源:互联网 发布:python wxpython 安装 编辑:程序博客网 时间:2024/06/06 03:57
p数组需要初始化。
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=10000+10;int s[maxn],p[maxn],f1[maxn],f2[maxn];int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) scanf("%d",&s[i]); memset(p,0x7f,sizeof(p));p[0]=0; int len=0; for(int i=1;i<=n;i++) { int pos=(int)(lower_bound(p+1,p+1+n,s[i])-p); len=max(len,pos); f1[i]=len; p[pos]=s[i]; } len=0; memset(p,0x7f,sizeof(p));p[0]=0; for(int i=n;i>=1;i--) { int pos=(int)(lower_bound(p+1,p+1+n,s[i])-p); len=max(len,pos); f2[i]=len; p[pos]=s[i]; } int maxlen=0; for(int i=1;i<=n;i++) if(f1[i]==f2[i]) maxlen=max(maxlen,f1[i]+f2[i]-1); cout<<maxlen<<endl; } return 0;}
0 0
- UVA 10534 Wavio Sequence(LIS O(nlogn))
- UVA 10534 Wavio Sequence LIS(nlogn实现)
- uva 10534 Wavio Sequence LIS 栈实现nlogn
- uva 10534 Wavio Sequence (LIS)
- UVa 10534 - Wavio Sequence LIS
- uva 10534 Wavio Sequence(LIS)
- UVA 10534 - Wavio Sequence LIS
- uva 10534 Wavio Sequence LIS
- UVA 10534 Wavio Sequence 【LIS】
- uva 10534 Wavio Sequence (LIS)
- uva 10534 Wavio Sequence nlogn方法
- uva 10534 - Wavio Sequence(nlgn复杂度LIS)
- UVA 10534 Wavio Sequence(dp + LIS)
- UVA 10534 Wavio Sequence (双向LIS)
- UVA - 10534 Wavio Sequence LIS 二分+DP
- UVa 10534 Wavio Sequence (LIS、LDS)
- UVA - 10534Wavio Sequence(LIS)
- UVA 10534Wavio Sequence(LIS)
- 敏捷软件开发与传统软件工程的比较
- 引用文献顺序纠正
- Linux下对JPEG图片进行简单压缩
- FormulaR1C1是EXCEL中单元格公式输入方法
- idea快捷键整理
- UVA 10534 Wavio Sequence(LIS O(nlogn))
- 顺序表的应用举例一(A-B)
- mysql备份及还原
- Notification 初学笔记
- PHP 基础知识四(正则表达式)
- UVA11078 BNU19496 Open Credit System
- HDU 2159 FATE 完全背包
- php---发送邮件
- uva806 spatial structures 空间结构