两边算一下LIS就出来了,因为数据比较大,所以需要二分优化一下。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; const int maxn = + ; int n; int a[maxn], l[maxn], r[maxn];
int g[maxn]; void LIS(int d[])
{
memset(g, 0x3f, sizeof(g));
for(int i = ; i < n; i++)
{
int k = lower_bound(g+, g++n, a[i]) - g;
d[i] = k;
g[k] = a[i];
}
} int main()
{
while(scanf("%d", &n) == )
{
for(int i = ; i < n; i++) scanf("%d", a + i);
LIS(l);
reverse(a, a + n);
LIS(r); int ans = ;
for(int i = ; i < n; i++) ans = max(ans, min(l[i], r[n--i]));
printf("%d\n", ans * - );
} return ;
}

代码君

UVa 10534 DP LIS Wavio Sequence的更多相关文章

  1. LIS UVA 10534 Wavio Sequence

    题目传送门 题意:找对称的,形如:123454321 子序列的最长长度 分析:LIS的nlogn的做法,首先从前扫到尾,记录每个位置的最长上升子序列,从后扫到头同理.因为是对称的,所以取较小值*2-1 ...

  2. uva 10534 Wavio Sequence LIS

    // uva 10534 Wavio Sequence // // 能够将题目转化为经典的LIS. // 从左往右LIS记作d[i],从右往左LIS记作p[i]; // 则最后当中的min(d[i], ...

  3. UVa 10534 Wavio Sequence (最长递增子序列 DP 二分)

    Wavio Sequence  Wavio is a sequence of integers. It has some interesting properties. ·  Wavio is of ...

  4. UVA 10534 三 Wavio Sequence

    Wavio Sequence Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Sta ...

  5. Codeforces Round #277 (Div. 2) E. LIS of Sequence DP

    E. LIS of Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/pr ...

  6. HOJ 2985 Wavio Sequence(最长递增子序列以及其O(n*logn)算法)

    Wavio Sequence My Tags (Edit) Source : UVA Time limit : 1 sec Memory limit : 32 M Submitted : 296, A ...

  7. BNUOJ 14381 Wavio Sequence

    Wavio Sequence Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA. Origina ...

  8. 【CF486E】LIS of Sequence题解

    [CF486E]LIS of Sequence题解 题目链接 题意: 给你一个长度为n的序列a1,a2,...,an,你需要把这n个元素分成三类:1,2,3: 1:所有的最长上升子序列都不包含这个元素 ...

  9. Codeforces 486E LIS of Sequence(线段树+LIS)

    题目链接:Codeforces 486E LIS of Sequence 题目大意:给定一个数组.如今要确定每一个位置上的数属于哪一种类型. 解题思路:先求出每一个位置选的情况下的最长LIS,由于開始 ...

随机推荐

  1. Win10系统特别卡的一个原因

    我遇到的Win10特别卡的原因是它自带的一个杀毒软件 迈克菲(McAfee)导致的,在卸载之前电脑真的特别卡,打开一个窗口都卡,,卸载了之后瞬间感觉电脑飞起来了.... 当然还有很多原因会导致电脑卡, ...

  2. jupyter notebook dead kernel问题解决

    背景: 我在刚安装好的tensorflow环境下启动jupyter notebook,无论是浏览器还是控制台,提示都是关于dead kernel.然后就查嘛,更新大发好. 但是我在控制台里按照其他人说 ...

  3. JMeter--PerfMon Metrics Collector监控内存及CPU

    1.需要准备的软件及插件 ServerAgent-2.2.1.zip JMeterPlugins-Standard-1.3.1.zip 2.jmeter上JMeterPlugins-Standard- ...

  4. I/O————字节流

    InputStream字节输入流 OutputStream字节输出流 用于以字节的形式读取和写入数据 下面是使用 字节输入流读取文件字节输出流写入文件 文件可能不存在,所以使用try catch pu ...

  5. PostgresSQL 数组包含@>

    原文链接:http://www.postgresql.org/docs/9.5/static/functions-array.html 9.18. Array Functions and Operat ...

  6. IP-XACT IP IEEE交换格式

    1 What is  IP-XACT?      IP-XACT is an XML format that defines and describes electronic components a ...

  7. [论文笔记] A Practical Architecture of Cloudification of Legacy Applications (2011, SERVICES)

    Dunhui Yu, Jian Wang, Bo Hu, Jianxiao Liu, Xiuwei Zhang, Keqing He, and Liang-Jie Zhang. 2011. A Pra ...

  8. X11/extensions/XShm.h: No such file or directory

    CentOS 编译一些开源项目提示:X11/extensions/XShm.h: No such file or directory. 运行命令:yum install libXext-devel就可 ...

  9. Linux OpenGL 实践篇-13-geometryshader

    几何着色器 几何着色器是位于图元装配和片元着色器之前的一个着色器阶段,是一个可选阶段.它的输入是一个图元的完整的顶点信息,通常来自于顶点着色器,但如果细分计算着色器启用的话,那输入则是细分计算着色器的 ...

  10. 查看进程lsof

    查看8000端口 lsof -i :8000 杀死进程 pkill -ns <pid>