Longest Ordered Subsequence POJ - 2533(dp动态规划)

poj-2533 Longest Ordered Subsequence 【最长上升子序列】 题目链接:http://poj.org/problem?id=2533 Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 35929   Accepted: 15778 Description A 阅读详情

Longest Ordered Subsequence

POJ - 2533

A numeric sequenceof ai is ordered if a1 < a2< ... < aN. Let the subsequence of the given numericsequence ( a1, a2, ..., aN)be any sequence ( ai1, ai2, ..., aiK),where 1 <= i1 < i2 < ... < iK<= N. For example, sequence (1, 7, 3, 5, 9, 4, 8) has orderedsubsequences, e. g., (1, 7), (3, 4, 8) and many others. All longest orderedsubsequences are of length 4, e. g., (1, 3, 5, 8).

Your program, when given the numeric sequence, must find the length of itslongest ordered subsequence.

Input

The first line ofinput file contains the length of sequence N. The second line contains theelements of sequence - N integers in the range from 0 to 10000 each, separatedby spaces. 1 <= N <= 1000

Output

Output file mustcontain a single integer - the length of the longest ordered subsequence of thegiven sequence.

Sample Input

7

1 7 3 5 9 4 8

Sample Output

4

题意:这个题就是经典的求最长上升子序列的问题,这个子序列可以是不连续的只需要满足i < j && a[i] < a[j]

下面介绍两种方法求解并加上我的理解

方法1:

这种方法是最普遍的想法,也很容易理解

定义dp[i] = 以ai为末尾的最长上升子序列,那么在以ai结尾的这个序列中,如果存在这么一个aj,使得j < i(这个条件可以通过循环条件硬性规定),并且aj < ai(这个就需要用if语句判断),那么此时以ai为结尾的最长上升子序列长度就是原本以aj为末尾的长度加一即dp[j]+1,否则等于它本身dp[i],每个dp[i]都初始化为1,代表只有他自身一个长度为一

那么这个问题就很清晰了下面是代码

code1:

#include <iostream>

#include <cstdio>

#include <cstring>

using namespace std;

#define MAXN 1009

int dp[MAXN];//dp[i]代表了一ai为结尾的递增序列的长度

int a[MAXN];

int n;

int main(){

    int i,j;

    cin >> n;

    for(i = 0; i< n; i++)

        cin>> a[i];

    int res = 0;

    for(i = 0; i< n; i++){

        dp[i] = 1;

        for(j = 0;j < i; j++){

            if(a[j]< a[i]){//满足 j<i && a[j] < a[i],那么dp[i] = 以aj为结尾的最长长度加1

               dp[i] = max(dp[i],dp[j]+1);

            }

        }

        res =max(res,dp[i]);//得到以当前ai为结尾的最长长度后选出最大的

    }

    cout <<res << endl;

    return 0;

}



方法2:

这个方法很巧妙,代码也很简洁,但是理解起来可能需要一定时间

我们重新定义dp[i] = 长度为i+1的上升子序列中末尾元素的最小值(不存在的话就是INF),单单是看这句话你可能就会有很多疑问

第一为什么是长度为i+1而不是i,其实这也是这个写法的巧妙之处,一会看代码的时候你会发现dp[i]的i是从0开始的,所以当然是代表长度i+1了。

第二为什么是最小值呢,因为如果子序列长度相同,那么最末尾元素较小的在之后求更长的会更有优势,因为我们就可以在这个的基础上求更长的了,如果你找了最大的,那长度就很难再变了

第三不存在怎么是INF,因为我们要dp定义的是末尾元素的最小值嘛,所以如果不存在我们就把他弄的大一些就可以了啊,所以就定义INF

那么接下来如果更新这个dp数组呢

首先初始化都为INF,然后我们是从前往后这个考虑元素的,所以对于每一个aj,如果i=0或者dp[i-1]<aj的话,说明什么呢?说明我们是不是可以把aj这个数放在dp[i]上了,也就是说成功的是长度增加了一个,这也又一次说明了我们为什么要用末尾元素的最小值。再说一遍aj在当前的dp数组找了一圈发现aj是最大的,所以aj放在了dp[i]上,那么反之,如果aj在dp数组里找了一圈发现自己不是最大的,大家想一想会怎么样呢,首先长度肯定不会增加了对吧,dp[i]还是INF,那么也一定说明aj肯定比dp中的某个数小对吧,再返回定义dp定义的是末尾元素最小对吧,那我们是不是把当前dp中第一个比aj大的数改成aj是不是就可以了,是的就是这样!记住这个分析。

仔细想一想上面红色字标注的分析,你发现了什么,我从前往后一个一个的看元素aj,是不是就是在dp数组中找第一个大于或者等于aj的数!!!,你又想到了什么,没错,这不就是c++提供的stl中lower_bound函数的用法吗,所以这个代码用lower_bound函数就可以实现啦,就是从前往后一个一个看,每个元素用lower_bound在dp里找,然后把当前aj

赋值给他即更新,那你可能又有疑问,lower_bound就是二分查找,必须是有序数列,那么这个dp是有序的吗,答案是肯定的,我问你,一开始都是INF,什么情况下才会把一个INF更改成原来数列中的一个数,当全是INF的时候对吧,其次呢,是不是如果这个数比原来已有的数都大,那么我用lower_bound找大于等于它的数是不是只有INF了,因此从一开始一直往后地推下去,dp数组一定是一个递增的序列(不断和lower_bound的查找规则联系起来想),那么对于dp的更新操作就完了,怎么输出答案

答案是不是就是最后一个的非INF的dp[i]的下标加一即一开始定义的i+1,但是我们并不知道最后一个是多少怎么找,一个方法遍历一边,下一个是INF就停止,然后输出i+1

其实还有更快的,直接用lower_bound找INF,那么它找到的肯定是第一个INF对吧,那么这个下标是不是恰好就是长度了(后移了一个嘛),但是lower_bound返回的是迭代器啊,直接-dp不就行了嘛,当指针用嘛

说了上面一堆,也不知道你们能不能看得下去,看没看得懂,反正看代码吧

code2:

 

#include <iostream>

#include <cstring>

#include <algorithm>

using namespace std;

#define MAXN 1009

#define INF 0x3f3f3f3f

int dp[MAXN];

int a[MAXN];

int main(){

    inti;

    intn;

    cin>> n;

   for(i = 0; i < n; i++){

       cin >> a[i];

    }

   memset(dp,INF,sizeof(dp));

   for(i = 0; i < n; i++){

       *lower_bound(dp,dp+n,a[i]) = a[i];//二分查找需要修改的点,并修改为当前值

    }

   cout << lower_bound(dp,dp+n,INF)-dp << endl;//找到第一个INF值,减去首地址就是实际长度,因为是数组是从0开始的,所以恰好是加一个到第一个INF值的下标

   return 0;

}


BPMN-JS :修改节点“Change Type”事件类型 修改路径:node_modules\bpmn-js\lib\features\replace\ReplaceOptions.js。 阅读详情

相关推荐

各种逻辑漏洞

注册:短信轰炸验证码安全问题密码爆破邮箱轰炸用户任意注册、批量注册用户名枚举XSS(有框的地方就可以尝试插XSS)登录:短信轰炸、验证码安全问题、密码爆破、邮箱轰炸SQL注入撞库抓包把password字段修改为空值发送认证凭证替换、比如返回的数据包中包含账号,修改账号就能登录到其他账号Cookie仿冒修改返回包的相关数据,可能会登陆到其他的用户找回密码:短信邮箱轰炸、短信邮箱劫持重置任意用户账户密码、验证码手机用户未统一验证直接跳过验证步骤。

shirlly_的博客 2091

Longest Ordered Subsequence 最长有序子数列 DP算法学习

因为我感觉这题是很简单的dp入门题(可以去看01背包问题),加深理解的话就去画图吧两个for演示一遍(如上)/* 我只是一个大一蒟蒻!欢迎大佬指点,若有不同意见可提出,共同学习!

m0_72913731的博客 271

SCL3400-D01双轴高精度倾角计

简介 两轴高精度加速度计,提供两个模式。 ±30° with 10 Hz LPF ±90° with 40 Hz LPF Resolution up to 32768 LSB/g Ultra-low 0.0009°/√Hz noise density 这款传感器是替换之前村田的停产的模拟量系列的芯片,正在测试中,具体效果大伙可以评测。 一、引脚连接图 引脚图兼容SCL3300 二、SPI接口 1.SCL3300和SCL3400略有区别如下图 左边为SCL3...

专注惯导领域 3807

poj2533

Longest Ordered Subsequence Time Limit:2000MS Memory Limit:65536K Total Submissions:18511 Accepted:7963 Description A numeric sequence ofaiis ordered ifa...

weixin_33763244的博客 305

保姆级教程:用Unidbg搞定阿里系App的x-sign和长x-mini-wua签名(附完整Java代码)

本文详细介绍了如何使用Unidbg框架模拟执行阿里系App的原生库,生成关键的x-sign和x-mini-wua签名参数。通过完整的Java代码示例和实战技巧,帮助开发者高效实现签名算法,适用于安全研究、数据分析和第三方应用开发场景。

weixin_29243279的博客 484

ubuntu18.04 显卡驱动问题 造成屏幕分辨变大 NVIDIA-SMI has failed because it couldn't communicate with ....等问题

问题1:装好了显卡驱动,cudnn,tensorflow等没问题,一直可以用。但是突然有一天不行了,终端输入:nvidia-smi 显示:NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed...

梦萦飞--CV/DL/ML 2248

POJ - 2533 Longest Ordered Subsequence (DP最长上升子序列)

                           Longest Ordered Subsequence Description A numeric sequence of ai is ordered if a1 &lt; a2 &lt; ... &lt; aN. Let the subsequence of the given numeric sequence (a1, a2, ...,...

K.X的博客 196

【新能源汽车DCDC变换器测试优化全攻略:解决电能质量/发热/过充等核心痛点】

高压直流转12V低压的DCDC变换器是新能源汽车电源系统的核心枢纽,承担着为整车低压附件、控制器及12V蓄电池供电/补电的关键作用。在新能源汽车乘用车、商用车等不同车型实际运营中,因PDU内DC/AC等模块干扰、DCDC自身设计缺陷、整车匹配性不佳及测试验证不充分,频发12V输出电能质量差导致后端元器件烧毁、变换器发热严重、蓄电池过充/欠充、智能补电功能失效等问题,还伴随低压侧电压瞬跌/浪涌、电磁干扰超标、振动后接触不良、高温下效率骤降等行业高频故障,直接影响整车可靠性和运营安全性。本文基于国标。

优快云-新能源汽车研发测试专业博主 1264

Longest Ordered Subsequence 最长有序子序列

Longest Ordered Subsequence Problem Description A numeric sequence of ai is ordered if a1 < a2 < … < aN. Let the subsequence of the given numeric sequence (a1, a2, …, aN) be any sequence (ai1, ai2, …, aiK), where 1 <= i1 < i2 < … < iK

MC的博客 832

面向RKNN平台的YOLOv11 Pose部署实战:模型转换、优化与端侧姿态估计推理

本文研究了YOLOv11 Pose模型在Rockchip RKNN平台上的部署方案。通过分析模型架构和关键技术,提出完整的转换流程,包括ONNX格式转换、检测头优化和量化配置。在RK3588硬件平台上实现了100 FPS的实时姿态检测,验证了该方案的可行性。研究主要贡献包括:1)提出YOLOv11 Pose到RKNN平台的完整转换方案;2)优化后处理算法;3)实现高效的边缘计算部署。实验结果表明,该方案能有效解决边缘设备计算资源受限的问题,为人机交互等应用场景提供了实用的技术方案。

m0_71589036的博客 612

基于STM32F103C8T6的智能蓝牙手环系统设计与实现

摘要:本文设计并实现了一款基于STM32F103C8T6单片机的智能蓝牙手环系统。该系统集成了ADXL345加速度计、DS18B20温度传感器、plusesennor心率模块和BT06蓝牙模块,实现了心率(±2bpm)、体温(±0.5℃)、步数(±3%)等健康数据的实时监测与显示。通过OLED屏提供人机交互界面,支持蓝牙APP远程控制,具备自动步数清零、异常提醒等功能。测试表明系统各项功能均达到设计要求,响应时间0.1-0.5秒,心率检测准确率98%,体温检测准确率99%,功耗50mA(工作)/10mA(待

3254968421的博客 205

Longest Ordered Subsequence(dp)

Description A numeric sequence of ai is ordered if a1 a2 aN. Let the subsequence of the given numericsequence (a1, a2, ..., aN)be any sequence (ai1, ai2, ..., aiK),where 1 i1 i2 iK N. For example,

practer的博客 285

UCIE Specification详解(五)

Logical Physical Layer(逻辑物理层)

Crazzy_M的博客 1221

poj 动态规划DP - 2533 Longest Ordered Subsequence

动态规划经典题:最长上升子序列。  假如我们考虑求A[1],A[2],…,A[i]的最长非降子序列的长度,其中i 为了方便理解我们是如何找到状态转移方程的,我先把下面的例子提到前面来讲。 如果我们要求的这N个数的序列是: 5,3,4,8,6,7 根据上面找到的状态,我们可以得到:(下文的最长非降子序列都用LIS表示) 前1个数的LIS长度d(1)=1(序列:5)前2

不要说话的博客 741

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

POJ 2533 Longest Ordered Subsequence(DP动态规划)

//DP动态规划,求最长上升子序列#includeint arr[1001],d[1001],len,max = 1;//最大值应初始化为1,因为最小值是1.当只有1个数据是输出1.int main(){ for(int i = 1;i <= 1000;++i) d[i] = 1;//将DP数组初始化为1 scanf("%d",&len); for(int i =

Czy 783

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

POJ 2533 Longest Ordered Subsequence (DP动态规划)

#include int seq[1001]; //lenOfLOSWithTai[i]表示已seq[i]为结尾的最长有序子序列的长度 int lenOfLOSWithTail[1001];//length of longest ordered sequence with tail int main(){ int lenOfSeq; scanf("%d", &lenOfSeq); i

TiuTiu Zone 471

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

poj入门水题--动态规划(DP)2533 Longest Ordered Subsequence 1088滑雪

9.2533 Longest Ordered Subsequence 最长子序列 1088 滑雪。 poj入门水题

薇酱的博客 790

POJ 2533 LIS N2

状态转移方程  dp[i]=max(dp[i],dp[j]+1); dp[i]为以第i个数结尾的能得到的最长的上升子序列。1http://poj.org/problem?id=2533Longest Ordered SubsequenceTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 34360Accepted: 15083Desc

chaideyipi 273

POJ 2533 Longest Ordered Subsequence

POJ 2533 Longest Ordered Subsequence Description A numeric sequence of ai is ordered if a1 < a2 < … < aN. Let the subsequence of the given numeric sequence (a1, a2, …, aN) be any sequence (ai...

旺崽的博客 3014

poj 2533 Longest Ordered Subsequence 深夜再来一波DP

A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK), where 1 <= i1 < i2 < ... < iK <= N. For example, sequence (1, 7, 3, 5, 9, 4, 8) has ordered

Lionel 1005

POJ2533-Longest Ordered Subsequence(dp)

POJ2533 原题链接:http://poj.org/problem?id=2533 Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 55259   Accepted: 24781 Descripti

Yorozuya 283

POJ_2533 Longest Ordered Subsequence【DP】【最长上升子序列】

POJ_2533 Longest Ordered Subsequence【DP】【最长递增子序列】 Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 58448 Accepted: 26207 Des...

dianxi0949的博客 128

POJ 2533 Longest Ordered Subsequence 解题报告

//考查点:动态规划(最长上升/不下降子序列 Longest Increasing Subsequence )。这题目是经典的DP题目,也可叫作LIS(Longest Increasing Subsequence)最长上升子序列 或者 最长不下降子序列 很基础的题目,有两种算法复杂度为O(n*logn)和O(n^2) 这题由于数据小,用后者O(n^2)即可  //思路: O(n^2)算

路雪军 Carl 2296

poj 2533 Longest Ordered Subsequence

Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 31423   Accepted: 13727 Description A numeric sequence of ai is ordered if a1 a2 a

逸疏 1015

POJ2533-Longest Ordered Subsequence【基础DP】

给出一个序列,求出这个序列的最长上升子序列。 序列A的上升子序列B定义如下: B为A的子序列 B为严格递增序列 Input 第一行包含一个整数n,表示给出序列的元素个数。 第二行包含n个整数,代表这个序列。 1 &lt;= N &lt;= 1000 Output 输出给出序列的最长子序列的长度。 思路:基础dp专题里的题,是最长单调子序列的板子题,贴上一个链接动态规划常见模型模板...

独钓门前月 352
上一篇: Working out CodeForces - 429B (四个角dp)
下一篇: You're Given a String... CodeForces - 23A
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值