传送门:

http://poj.org/problem?id=2533

Longest Ordered Subsequence
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 61731   Accepted: 27632

Description

A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK), where 1 <= i1 < i2 < ... < iK <= N. For example, sequence (1, 7, 3, 5, 9, 4, 8) has ordered subsequences, e. g., (1, 7), (3, 4, 8) and many others. All longest ordered subsequences are of length 4, e. g., (1, 3, 5, 8).

Your program, when given the numeric sequence, must find the length of its longest ordered subsequence.

Input

The first line of input file contains the length of sequence N. The second line contains the elements of sequence - N integers in the range from 0 to 10000 each, separated by spaces. 1 <= N <= 1000

Output

Output file must contain a single integer - the length of the longest ordered subsequence of the given sequence.

Sample Input

7
1 7 3 5 9 4 8

Sample Output

4

Source

Northeastern Europe 2002, Far-Eastern Subregion
 
分析:
完全裸露的LIS
 
code:
#include<stdio.h>
#define MAXN 1000
int dp[MAXN+],a[MAXN+];//a数组记录输入的序列
int main()
{
int n,i,j;
scanf("%d",&n);
for(i=;i<=n;i++)
scanf("%d",&a[i]);
dp[]=;
for(i=;i<=n;i++)
{
int temp=;
for(j=;j<i;j++)
if(a[i]>a[j])
if(temp<dp[j])
temp=dp[j];
dp[i]=temp+;
}
int maxlen=;
for(i=;i<=n;i++)
if(maxlen<dp[i])
maxlen=dp[i];
printf("%d\n",maxlen);
return ;
}

POJ 2533 Longest Ordered Subsequence(裸LIS)的更多相关文章

  1. POJ 2533 Longest Ordered Subsequence(LIS模版题)

    Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 47465   Acc ...

  2. Poj 2533 Longest Ordered Subsequence(LIS)

    一.Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequenc ...

  3. POJ 2533 Longest Ordered Subsequence (LIS DP)

    最长公共自序列LIS 三种模板,但是邝斌写的好像这题过不了 N*N #include <iostream> #include <cstdio> #include <cst ...

  4. poj 2533 Longest Ordered Subsequence 最长递增子序列

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4098562.html 题目链接:poj 2533 Longest Ordered Subse ...

  5. POJ 2533 - Longest Ordered Subsequence - [最长递增子序列长度][LIS问题]

    题目链接:http://poj.org/problem?id=2533 Time Limit: 2000MS Memory Limit: 65536K Description A numeric se ...

  6. LIS(n^2) POJ 2533 Longest Ordered Subsequence

    题目传送门 题意:LIS(Longest Increasing Subsequence)裸题 分析:状态转移方程:dp[i] = max (dp[j]) + 1   (a[j] < a[i],1 ...

  7. poj 2533 Longest Ordered Subsequence(LIS)

    Description A numeric sequence of ai is ordered ifa1 <a2 < ... < aN. Let the subsequence of ...

  8. POJ - 2533 Longest Ordered Subsequence与HDU - 1257 最少拦截系统 DP+贪心(最长上升子序列及最少序列个数)(LIS)

    Longest Ordered Subsequence A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let ...

  9. 题解报告:poj 2533 Longest Ordered Subsequence(最长上升子序列LIS)

    Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence ...

随机推荐

  1. 【计算机网络】详解HttpURLConnection

    请求响应流程 设置连接参数的方法 setAllowUserInteraction setDoInput setDoOutput setIfModifiedSince setUseCaches setD ...

  2. js 标签属性与导航

    导航标签的方法:  一 , 全局导航: 1.通过by id导航 <!DOCTYPE html><html lang="en"><head> &l ...

  3. BlackLowKey主题CSS

    /* Minification failed. Returning unminified contents. (151,61): run-time error CSS1062: Expected se ...

  4. Csharp

    c#简介 c#程序结构 c#基本语法 c#数据类型 c#类型转换 c#变量 c#常量 c#运算符 c#判断 c#循环 c#方法 c#简介 C# 是一个现代的.通用的.面向对象的编程语言,它是由微软(M ...

  5. sql server 数据库代码备份及还原代码

    --备份 BACKUP DATABASE [库名称] TO DISK='E:\qq\ddd.bak' --备份并覆盖 BACKUP DATABASE [库名称] TO DISK='E:\qq\ddd. ...

  6. linux漏洞分析入门笔记-栈溢出

    ida7.0 ubuntu16.04 lts 0x00:环境配置 使用IDA远程调试Linux程序步骤如下: 1. 在进行远程调试之前需要对Linux平台进行一些准备工作.在IDA的安装目录中的dbg ...

  7. SQL Server ->> 重命名数据库

    ALTER DATABASE [oldDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE [oldDB] MODIFY NAME ...

  8. Oracle分区表分批迁移

    遇到个分区表数据量超大的case,磁盘空间不够,所以考虑使用数据泵分批导数据,测试如下: source : oracle windows 32bit 10.2.0.1target  :  oracle ...

  9. May 22nd 2017 Week 21st Monday

    The biggest adventure you can take is to live the life of your dreams. 你能经历的最大的冒险,就是过上你梦想的生活. Just l ...

  10. MATLAB安装与注册(血泪总结)

    工具/原料   R2016a_win64.iso(安装文件) Matlab 2016a Win64 Crack.rar(破解文件) 方法/步骤   1 下载R2016a_win64.iso(安装文件) ...