POJ-2533(最长上升子序列(简单dp))
来源:互联网 发布:ssh2框架搭建实例源码 编辑:程序博客网 时间:2024/06/15 01:31
题目名称:Longest Ordered Subsequence 题目链接:https://vjudge.net/problem/POJ-2533简单的动态规划, 状态转移方程为:dp[i] = max(dp[i], dp[j] + 1) 当 a[j] > a[i] && j < i;
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 1005;int a[MAXN], dp[MAXN];int main(){ int n; while(scanf("%d", &n) != EOF) { for(int i = 0; i < n; ++i) scanf("%d", &a[i]); //dp int res = -1; for(int i = 0; i < n; ++i) { dp[i] = 1; for(int j = 0; j < i; ++j) if(a[j] < a[i]) dp[i] = max(dp[i], dp[j]+1); res = max(res, dp[i]); } printf("%d\n", res); } return 0;}
阅读全文
0 0
- 简单的dp@POJ(3)2533 最长上升子序列
- POJ-2533(最长上升子序列(简单dp))
- HDU 1087 && POJ 2533(DP,最长上升子序列).
- poj 2533 最长上升子序列
- poj 2533 最长上升子序列
- poj 2533最长上升子序列
- poj 2533 最长上升子序列
- 最长上升子序列 nlogn poj 2533
- poj 2533 最长上升子序列
- 最长上升子序列 POJ 2533
- poj 2533 最长上升子序列
- POJ 2533 最长上升子序列
- 最长上升子序列 dp
- DP--最长上升子序列
- DP LIS(最长上升子序列) POJ 2533 POJ 1836 POJ 2138 HDU 1069
- POJ 1836Alignment(DP最长上升子序列)
- 矩形嵌套 简单DP 最长上升子序列
- 关于最长上升子序列的算法 简单dp
- 优秀控件搜集
- 提升代码可读性的 10 个技巧
- jasper报表通过Java生成pdf中文不显示的一种解决方案
- 运算符
- mybatis分页插件MicroPageInterceptor
- POJ-2533(最长上升子序列(简单dp))
- 高级网络配置
- ionic项目编写bug记录
- TensorFlow实现简单的车辆检测
- 阿里云第四代云服务器性能有哪些提升,价格如何,你知道吗?
- 利用线程发送实时消息并在不需要时移除子线程
- 30分钟掌握ES6/ES2015核心内容(下)
- Encog3Java-User.pdf翻译:第四章 使用Java构建神经网络
- [leetcode]#189. Rotate Array