两边算一下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. DB2 错误 54001

    DB2 语句太长或者太复杂 SQLSTATE=54001 对数据库的参数的修改: db2 update db cfg for DB_NAME using STMTHEAP 4096 db2 updat ...

  2. Linux crontab 设置定时任务

    crontab crontab 用于设置系统自动执行的周期性任务 # m h dom mon dow user command 17 * * * * root cd / && run- ...

  3. Linux 安装gcc4.8版本

    1.下载安装包 http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.1/ 2.解压 .tar.gz 3.下载编译所需的依赖包 cd ...

  4. Nginx 配置https 开启ssl 同时支持http

    server { listen ; listen 443 ssl; server_name default; index index.html index.php; root /www/html; a ...

  5. React 实践记录 04 Flux demo

    Introduction flux应用架构如下图所示,本文并不是讲述怎么立即做一个酷炫的应用,而是讲述如何依照这种框架,来进行代码的组织. 我们先把这个流程转述为文字:抛开与webAPI的交互不谈,以 ...

  6. matlab载入图像,旋转,裁剪 保存

    clc;clear all;close all src=imread('C:\Users\think\Desktop\12.jpg'); subplot(,,) imshow(src); I = ma ...

  7. IOS拉伸之底盖设置

    1.选定拉伸 UIImageView *fieldImage=[[UIImageViewalloc]initWithFrame:CGRectMake(37,48+35,240, 32)]; field ...

  8. Selenium私房菜系列10 -- 我遇到的问题及解决问题的方法

    Selenium私房菜系列10 -- 我遇到的问题及解决问题的方法

  9. 基于51单片机个LCD1602的万年历程序

    小白 第一次跟新博客 基于51单片机和LCD1602的万年历程序 可实现走时和调时功能 有简单的1602菜单制作 欢迎大家交流 LCD1602和51单片机的连接方法 RS = P3^5; //数据/命 ...

  10. iPhone Tutorials

    http://www.raywenderlich.com/tutorials This site contains a ton of fun written tutorials – so many t ...