Longest Ordered Subsequence
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 55490   Accepted: 24881

Description

A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1a2, ..., aN) be any sequence (ai1ai2, ..., 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
 #include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long LL ;
typedef unsigned long long ULL ;
const int maxn = + ;
const int inf = 0x3f3f3f3f ;
const int npos = - ;
const int mod = 1e9 + ;
const int mxx = + ;
const double eps = 1e- ;
const double PI = acos(-1.0) ; int a[maxn], dp[maxn], ans, n;
int main(){
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
while(~scanf("%d",&n)){
ans=;
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
dp[i]=;
for(int j=i-;j>;j--)
if(a[i]>a[j])
dp[i]=max(dp[i],dp[j]+);
ans=max(ans,dp[i]);
}
printf("%d\n",ans);
}
return ;
}

POJ_2533_Longest Ordered Subsequence的更多相关文章

  1. POJ 2533 Longest Ordered Subsequence(最长上升子序列(NlogN)

    传送门 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subseque ...

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

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

  3. POJ 2533 Longest Ordered Subsequence 最长递增序列

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

  4. POJ2533——Longest Ordered Subsequence(简单的DP)

    Longest Ordered Subsequence DescriptionA numeric sequence of ai is ordered if a1 < a2 < ... &l ...

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

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

  6. POJ2533 Longest ordered subsequence

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

  7. POJ2533:Longest Ordered Subsequence(LIS)

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

  8. poj2533--Longest Ordered Subsequence(dp:最长上升子序列)

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

  9. POJ 2533-Longest Ordered Subsequence(DP)

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

随机推荐

  1. MySQL--指定浮点型数据的精确度TRUNCATE

    INSERT INTO perf_week(node_id,perf_time,pm25,pm10,temp,humi) ) ) ) ) AS humi FROM perf_pm25 WEEK) AN ...

  2. grid简单布局

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. python使用代理访问服务器

    python使用代理访问服务器主要有一下3个步骤: 1.创建一个代理处理器ProxyHandler: proxy_support = urllib.request.ProxyHandler(),Pro ...

  4. Explaining Delegates in C# - Part 4 (Asynchronous Callback - Way 1)

    So far, I have discussed about Callback, Multicast delegates, Events using delegates, and yet anothe ...

  5. Git 学习笔记--1.Git基础操作

    取得项目的Git仓库 有两种方式取得Git项目仓库.第一种是在现存的目录下,通过导入所有文件来创建新的Git仓库.第二种是从已有的Git仓库克隆出一个新的镜像仓库. 在工作目录中初始化新仓库  要对现 ...

  6. Kubernetes kubectl 命令

    kubectl 命令用来操作 Kubernetes 集群中的资源对象,包括对资源的创建.删除.查看.修改.配置.运行等 命令语法:kubectl [command] [TYPE] [NAME] [fl ...

  7. 发送http请求

    public static String httpGetSend(String url) { String responseMsg = ""; HttpClient httpCli ...

  8. web移动前端页面,jquery判断页面滑动方向

    /*判断上下滑动:*/ $('body').bind('touchstart',function(e){ startX = e.originalEvent.changedTouches[0].page ...

  9. Matlab 矩阵函数

    clear; clc; A = rand() cond(A) %求矩阵A的条件数 Det(A) %求方阵A的行列式 Dot(A,B) %矩阵A与B的点积 Eig(A) %方阵A的特征值和特征向量 No ...

  10. Nginx七层反向代理和负载均衡

    1.介绍 1.1 Nginx不仅是一个出色的web软件,其七层代理和负载均衡也是相当出色.Nginx做前端代理,当用户请求服务时,可以根据url进行判断,然后分配到不同的后台webserver上. 1 ...