题目链接: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. css实战#用css画一个中国结

    大家好!今天跟大家分享一个用 css 画中国结的教程.最终效果如下: 大家如果感兴趣可以参考我的源码:gitHub地址 首先,我们定义好画中国结需要的结构: <div class="k ...

  2. js中的内置方法的兼容写法

    1.如果浏览器不支持every属性,every的实现原理 if(Array.prototype.every===undefined){ Array.prototype.every=function(f ...

  3. python入门到放弃-基本数据类型之dcit字典

    1.概述 字典是python中唯一的一个映射类型,以{}大括号括起来的键值对组成 字典中的key是唯一的,必须是可hash,不可变的数据类型 语法:{key1:value,key2:value} #扩 ...

  4. 测试后的iview的表格

    <template>   <GPage bg>     <div>       <div class="table">        ...

  5. CrawlSpiders简介

    转:https://www.cnblogs.com/ellisonzhang/p/11124516.html#4295547 一.CrawlSpiders类简介 通过下面的命令可以快速创建 Crawl ...

  6. python中那些让开发事半功倍的模块

    1. Map Map会将一个函数映射到一个输入列表的所有元素上 ex: 有一个列表: [1,2,3,4,5,6], 现在要求把列表每个元素乘以10 如果你还不知道Map,那你可能会这样做: list1 ...

  7. 文件合并cat and paste

    cat 纵向合并 cat file1 file 2 paset横向合并 wc用法 sort用法

  8. 038.集群网络-K8S网络实现

    一 Kubernetes网络实现 1.1 Kubernetes网络优势 在实际的业务场景中,业务组件之间的关系十分复杂,微服务的理念更是让应用部署的粒度更加细小和灵活.为了支持业务应用组件的通信,Ku ...

  9. The instance of entity type 'manager' cannot be tracked because another instance with the same key value for {'id'} is already being tracked. When attaching existing entities, ensure that only one ent

    最近在用ASP.NET CORE时遇到一些问题,现记录下: 出现上述错误,即在更新实体数据时出现的错误 services.AddDbContext<StoreContext>(c => ...

  10. 【转】在Eclipse下,出现“找不到或无法加载主类 ”的问题的解决方式

    实际上是第一次碰到这个问题,之前从来没有遇见过,于是乎就开始找“度娘”帮忙,一搜发现有很多的程序猿都遇到这个问题.网上大部分的解决方案都是说“环境变量”配置有错误,当然这确实是引发“找不到或无法加载主 ...