题目链接:http://poj.org/problem?id=2533

描述:

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.

翻译:

找一串数字最长上升子序列的数字个数。(手动狗头)

没有难度的一个dp题,范围不算大,最普通的方法就可以过了

想优化看到了其他博主说的二分,不过我没有用

等复习到二分再来试试吧

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std; int read(){
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} int n,a[],dp[],ans; int main(){
n=read();
for(int i=;i<=n;i++)
a[i]=read();
for(int i=;i<=n;i++)
for(int j=;j<i;j++)
if(a[i]>a[j])dp[i]=max(dp[i],dp[j]+);
for(int i=;i<=n;i++)
ans=max(ans,dp[i]);
cout<<ans+;
return ;
}

[POJ2533]Longest Ordered Subsequence<dp>的更多相关文章

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

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

  2. POJ2533 Longest ordered subsequence

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

  3. POJ2533 Longest Ordered Subsequence 【最长递增子序列】

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

  4. (线性DP LIS)POJ2533 Longest Ordered Subsequence

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

  5. poj-2533 longest ordered subsequence(动态规划)

    Time limit2000 ms Memory limit65536 kB A numeric sequence of ai is ordered if a1 < a2 < ... &l ...

  6. POJ2533 Longest Ordered Subsequence —— DP 最长上升子序列(LIS)

    题目链接:http://poj.org/problem?id=2533 Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 6 ...

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

    本题大意:和LIS一样 本题思路:用dp[ i ]保存前 i 个数中的最长递增序列的长度,则可以得出状态转移方程dp[ i ] = max(dp[ j ] + 1)(j < i) 参考代码: # ...

  8. POJ2533 Longest Ordered Subsequence (线性DP)

    设dp[i]表示以i结尾的最长上升子序列的长度. dp[i]=max(dp[i],dp[j]+1). 1 #include <map> 2 #include <set> 3 # ...

  9. POJ2533:Longest Ordered Subsequence(LIS)

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

随机推荐

  1. java调用DLL,打印二维码标签

    package com.ian.das.controller; import java.util.List; import org.xvolks.jnative.JNative; import org ...

  2. Simulink仿真入门到精通(四) Simulink子系统

    4.1 Simulink子系统详解 4.1.1 子系统概述 Simulink根据仿真特性将模块的属性分为两种:虚拟模块和非虚拟模块. 非虚拟模块在仿真过程中起到实际的作用,对其进行编辑或者增加删除操作 ...

  3. 智慧树刷网课python脚本

    0x00 写在前面 疫情期间肯定有很多小伙伴需要上网课,但是有些网课我们感觉十分的鸡肋,自己不感兴趣,又必须要学 所以我写了这个刷网课的小程序,一方面是锻炼自己的爬虫技术,另一方面也给同学们节约宝贵的 ...

  4. Drf 序列化 ModelSerializer跨表取数据

    1.对于OneToOne.Foreignkey.choices字段可以使用source取出相关信息: class CourseSerializer(serializers.ModelSerialize ...

  5. Java安装和配置

    一. Java安装和配置 1.JDK下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-21331 ...

  6. div中单行文字垂直水平居中

    1.div中单行文字垂直水平居中.条件:外层div高度已经给定.代码如下: 复制代码代码如下: <style type="text/css">.div3{border: ...

  7. js Number方法总结

    Number构造属性 Number.EPSILON // 两个可表示(representable)数之间的最小间隔. Number.MAX_SAFE_INTEGER // JavaScript 中最大 ...

  8. 2016 Multi-University Training Contest 4 T9

    http://acm.hdu.edu.cn/showproblem.php?pid=5772 最大权闭合子图. 得到价值w[i][j]的条件是选了i,j这两个位置的字符.选择位置的i字符花费为 第一次 ...

  9. Journal of Proteome Research | Current understanding of human metaproteome association and modulation(人类宏蛋白质组研究近期综述)(解读人:李巧珍)

    文献名:Current understanding of human metaproteome association and modulation(人类宏蛋白质组研究近期综述) 期刊名:J Prot ...

  10. Mol. Cell. Proteomics | 癌细胞衍生的小细胞外囊体通过促进HGF-Met途径促进受体细胞转移

    题目:Cancer cell derived small extracellular vesicles contribute to recipient cell metastasis through ...