#include <iostream.h>
void main()
{
int i,j,a[14]={5,6,-6,-1,9,10,-5,-3,16,4,3,-4,-3,5};
int dp[14];
for(i=0;i<14;i++)
dp[i]=1;
for(i=1;i<14;i++)
for(j=0;j<i;j++)
if(a[j]<a[i] && dp[j]+1>dp[i])
dp[i]=dp[j]+1;
for(i=0;i<14;i++)
cout<<a[i]<<"\t"<<dp[i]<<endl;
}
  •   This state carries only data about the length of this sequence. Note that for i<j the state i is independent from j, i.e. doesn’t change when we calculate state j.
  • https://www.topcoder.com/community/competitive-programming/tutorials/dynamic-programming-from-novice-to-advanced/

dp:最长非递减序列的更多相关文章

  1. HDU 5532 Almost Sorted Array (最长非递减子序列)

    题目链接 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort, heap s ...

  2. HDU 6357.Hills And Valleys-字符串非严格递增子序列(LIS最长非下降子序列)+动态规划(区间翻转l,r找最长非递减子序列),好题哇 (2018 Multi-University Training Contest 5 1008)

    6357. Hills And Valleys 自己感觉这是个好题,应该是经典题目,所以半路选手补了这道字符串的动态规划题目. 题意就是给你一个串,翻转任意区间一次,求最长的非下降子序列. 一看题面写 ...

  3. Codeforces Round #323 (Div. 2) D. Once Again... 暴力+最长非递减子序列

                                                                                  D. Once Again... You a ...

  4. Codeforces Round #581 (Div. 2)D(思维,构造,最长非递减01串)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;char s[100007];int main ...

  5. HDU 6357.Hills And Valleys-动态规划(区间翻转l,r找最长非递减子序列)

    题意:给一串由n个数字组成的字符串,选择其中一个区间进行翻转,要求翻转后该字符串的最长非降子序列长度最长,输出这个最长非降子序列的长度以及翻转的区间的左右端点 #include<bits/std ...

  6. HDU 1025 Constructing Roads In JGShining's Kingdom[动态规划/nlogn求最长非递减子序列]

    Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

  7. dp最长不下降序列

    // // Created by snnnow on 2020/4/13. // //这是dp 问题的基础题 // //最长不下降 //(导弹拦截是其例题) //那这篇文章是讲啥呢, // 主要是吧, ...

  8. Codeforces Round #321 (Div. 2) A. Kefa and First Steps【暴力/dp/最长不递减子序列】

    A. Kefa and First Steps time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  9. dp(最长升序列:二分查找时间优化nlogn)

    We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, sele ...

随机推荐

  1. java实现 TCP通信

    //服务端import com.hl.bluetooth.util.CRC16; import com.hl.bluetooth.util.FrameCheckFailedException; imp ...

  2. apache缺少模块解决方法

    找到一台老古董机器 [root@resource conf]# cat /etc/redhat-release CentOS release 5.6 (Final) [root@resource co ...

  3. [数分笔记]Dedekind切割定理的证明

    1.定理内容 Dedekind切割定理:设是实数集的一个切割,则或者有最大数,或者有最小数. 2.证明过程 设是中所有有理数所构成的集合,是中所有有理数所构成的集合 从而构成一个有理数集的切割 有三种 ...

  4. 思迈特软件Smartbi光鲜亮丽的背后是什么在支撑?

    思迈特软件Smartbi是国内知名BI厂商,自2011年成立以来就以提升和挖掘客户的价值为使命,致力于为客户提供一站式商业智能平台和BI解决方案,发展到如今已经获得了来自国家.地方政府.国内外权威分析 ...

  5. windows 常用的shell(cmd.exe)命令大全

    Windows常用shell命令大全(转) [Windows常用shell命令大全] 基于鼠标操作的后果就是OS界面外观发生改变, 就得多花学习成本.更主要的是基于界面引导Path与命令行直达速度是难 ...

  6. C#基于Redis实现分布式锁

    [本博客属于原创,如需转载,请注明出处:https://www.cnblogs.com/gdouzz/p/12097968.html] 最近研究库存的相关,在高峰期经常出现超卖等等情况,最后根据采用是 ...

  7. 给页面添加Canvas鼠标光标星星跟随动画特效

    素材来源:https://www.lanrenzhijia.com/others/5024.html 简单说下我自己的步骤: 把<script type="text/javascrip ...

  8. Codeforces Round #773 (Div. 2)D,E

    D. Repetitions Decoding 传送门 题目大意: 一个长为 n ( n 2 ≤ 250000 ) n(n^2\leq250000) n(n2≤250000)的序列,每个元素 a i ...

  9. 《Selenium+Pytest Web自动化实战》视频试听课程

    环境准备 1.1 python3环境安装 1.2 selenium3和chrome环境 1.3 pycharm安装 webdriver API 2.1基本操作 2.2元素定位id_name_class ...

  10. httpHelper 从URL获取值

    /// <summary> /// 从URL获取值(字符串) /// </summary> public static string GetValueFromUrl(strin ...