Longest Ordered Subsequence POJ - 2533 dp 最长上升/不下降 子序列
#include<iostream>
using namespace std ;
const int N=;
int f[N];
int a[N];
int n;
int main() {
cin>>n;
for(int i=; i<=n; i++) cin>>a[i];
for(int i=; i<=n; i++) {
f[i]=;
for(int j=; j<=i; j++) {
if(a[j]<a[i]) {
f[i]=max(f[i],f[j]+);
}
}
}
int res=;
for(int i=; i<=n; i++) res=max(res,f[i]);
cout<<res<<endl;
return ;
}
Longest Ordered Subsequence POJ - 2533 dp 最长上升/不下降 子序列的更多相关文章
- Longest Ordered Subsequence POJ - 2533 最长上升子序列dp
题意:最长上升子序列nlogn写法 #include<iostream> #include<cstdio> #include<cstring> #include&l ...
- POJ2533——Longest Ordered Subsequence(简单的DP)
Longest Ordered Subsequence DescriptionA numeric sequence of ai is ordered if a1 < a2 < ... &l ...
- poj 2533 Longest Ordered Subsequence(线性dp)
题目链接:http://poj.org/problem?id=2533 思路分析:该问题为经典的最长递增子序列问题,使用动态规划就可以解决: 1)状态定义:假设序列为A[0, 1, .., n],则定 ...
- POJ 2533 Longest Ordered Subsequence (LIS DP)
最长公共自序列LIS 三种模板,但是邝斌写的好像这题过不了 N*N #include <iostream> #include <cstdio> #include <cst ...
- POJ2533 Longest Ordered Subsequence (线性DP)
设dp[i]表示以i结尾的最长上升子序列的长度. dp[i]=max(dp[i],dp[j]+1). 1 #include <map> 2 #include <set> 3 # ...
- 【POJ - 2533】Longest Ordered Subsequence (最长上升子序列 简单dp)
Longest Ordered Subsequence 搬中文 Descriptions: 给出一个序列,求出这个序列的最长上升子序列. 序列A的上升子序列B定义如下: B为A的子序列 B为严格递增序 ...
- POJ 2533 Longest Ordered Subsequence(DP 最长上升子序列)
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 38980 Acc ...
- POJ - 2533 Longest Ordered Subsequence与HDU - 1257 最少拦截系统 DP+贪心(最长上升子序列及最少序列个数)(LIS)
Longest Ordered Subsequence A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let ...
- poj 2533 Longest Ordered Subsequence 最长递增子序列
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4098562.html 题目链接:poj 2533 Longest Ordered Subse ...
随机推荐
- vue自由拖拽、缩放组件
github地址:https://github.com/kirillmurashov/vue-drag-resize 安装: npm i -s vue-drag-resize 使用: <temp ...
- React Native运行出现Could not find "iPhone X" simulator
打开项目文件夹下 node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js 查找 if (!version.startsW ...
- appium server与nodeJs 兼容问题
在命令行模式下启动appium server时报错:error: uncaughtException: Cannot find module 'internal/util/types' 再来看看app ...
- [Contract] Solidity 遍历 mapping 的一种方式
思路:为需要遍历的 mapping 再准备一个 list,之后通过 for 循环遍历 list 取得 mapping 的 key. mapping (address => uint) users ...
- CF #623 div.2
序 话说,总有人认为我是黑别人电脑的(雾??其实,我不黑电脑,我黑手机. T1 此题巨水,比较四个面积就就好了.. /* make by ltao */ #include <iostream&g ...
- Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set…
php打印小票错误提示:Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activate ...
- css基础-定位+网页布局案例
position:static 忽略top/bottom/left/right或者z-index position:relative 设置相对定位的元素不会脱离文档流 position:fixed 不 ...
- C# 图片转为Base64
/// <summary> /// 图片转Base64 /// </summary> /// <param name="ImageFileName"& ...
- 封装的Redis队列
封装的Redis队列 MyRedisQueue.py #!usr/bin/env python2.7 # -*- coding: utf-8 -*- import redis class RedisQ ...
- Math Magic ZOJ - 3662
核心是要想到只枚举最小公倍数的因子 因为转移过程中一单添加了不是最小公倍数的因子,那么结果必然不合法,虽然最终答案是对的,但是这样的答案根本用不上,反而时间复杂度大大增加 #include<cs ...