This is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence.

InputEach sequence is described with M - its length (1 <= M <= 500) and M integer numbers Ai (-2^31 <= Ai < 2^31) - the sequence itself.Outputoutput print L - the length of the greatest common increasing subsequence of both sequences.Sample Input

1

5
1 4 2 5 -12
4
-12 1 2 4

Sample Output

2

注意一下控制格式
 #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<string.h>
using namespace std; int a[];
int b[];
int dp[]; int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
int tt;
cin>>tt;
while(tt--)
{
memset(a,,sizeof(a));
memset(b,,sizeof(b));
memset(dp,,sizeof(dp));
int p,q;
cin>>p;
for(int i=;i<p;i++)
cin>>a[i];
cin>>q;
for(int i=;i<q;i++)
cin>>b[i];
int maxx;
for(int i=;i<p;i++)
{
maxx=;//每次都要恢复
for(int j=;j<q;j++)
{
if(a[i]>b[j])
maxx=max(dp[j],maxx);
else if(a[i]==b[j])
dp[j]=maxx+;
}
}
int ans=;
for(int i=;i<q;i++)
ans=max(ans,dp[i]);
if(tt)
cout<<ans<<endl<<endl;
else
cout<<ans<<endl;
}
return ;
}
												

HDU-1423-Greatest Common Increasing Subsequence-最长公共上升子序列【模版】的更多相关文章

  1. HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS)

    HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS) http://acm.hdu.edu.cn/showproblem.php?pi ...

  2. HDU 1423 Greatest Common Increasing Subsequence(LICS入门,只要求出最长数)

    Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536 ...

  3. HDU 1423 Greatest Common Increasing Subsequence LCIS

    题目链接: 题目 Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...

  4. HDU 1423 Greatest Common Increasing Subsequence(LCIS)

    Greatest Common Increasing Subsequenc Problem Description This is a problem from ZOJ 2432.To make it ...

  5. HDU 1423 Greatest Common Increasing Subsequence

    最长公共上升子序列   LCIS 看这个博客  http://www.cnblogs.com/nuoyan2010/archive/2012/10/17/2728289.html #include&l ...

  6. HDU 1423 Greatest Common Increasing Subsequence ——动态规划

    好久以前的坑了. 最长公共上升子序列. 没什么好说的,自己太菜了 #include <map> #include <cmath> #include <queue> ...

  7. HDOJ 1423 Greatest Common Increasing Subsequence 【DP】【最长公共上升子序列】

    HDOJ 1423 Greatest Common Increasing Subsequence [DP][最长公共上升子序列] Time Limit: 2000/1000 MS (Java/Othe ...

  8. HDOJ 1423 Greatest Common Increasing Subsequence -- 动态规划

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1423 Problem Description This is a problem from ZOJ 2 ...

  9. POJ 1423 Greatest Common Increasing Subsequence【裸LCIS】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1423 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  10. HDUOJ ---1423 Greatest Common Increasing Subsequence(LCS)

    Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536 ...

随机推荐

  1. 网址URL知识

    URL由三部分组成:资源类型.存放资源的主机域名.资源文件名. URL的一般语法格式为: (带方括号[]的为可选项): protocol :// hostname[:port] / path / [; ...

  2. html input 上capture 参数在 安卓 苹果上的异同

    安卓上 <input type="file" accept="image/*" capture="camera"> //只调用相 ...

  3. windows下安装jenkins初级(2)

    这里是基于gitlab拉取代码     gitlab暂时先不多介绍     我们需要把git和gitlab连接起来方便拉取代码     所以需要git的ssh公匙和私匙     首先在   https ...

  4. python 客户端 httplib 、 requests分别post数据(soap)

    httplib import httplib soapbody =''' <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap ...

  5. Superset安装出错 sqlalchemy.exc.InvalidRequestError: Can't determine which FROM clause to join from, ...

    $ superset db upgrade ... Traceback (most recent call last): File "/home/jhadmin/.pyenv/version ...

  6. 从psd图中将图层导出成单独文件

  7. QueryList getData()方法中多次调用来实现递归多级采集。

    <?php require 'QueryList/vendor/autoload.php'; use QL\QueryList; //获取每个li里面的h3标签内容,和class为item的元素 ...

  8. NX二次开发-创建直线UF_CURVE_create_line与NXOpen->CreateLine

    NX11+VS2013 #include <uf.h> #include <uf_curve.h> #include <NXOpen/CurveCollection.hx ...

  9. JS常见的报错类型

    解决错误前,首先要学会阅读报错信息 eg:Uncaught TypeError: ... is not a function Uncaught 表示没有被catch语句捕获到的错误 TypeError ...

  10. iOS13适配/黑暗模式的适配/KVC访问私有属性/模态弹窗ViewController 默认样式改变 /LaunchImage即将废弃/蓝牙的权限申请/推送Device Token适配/UIKit 控件变化/StatusBar新增样式

    目录 1. KVC访问私有属性 2. 模态弹窗ViewController 默认样式改变 3. 黑暗模式的适配 4. LaunchImage即将废弃 5. 新增一直使用蓝牙的权限申请 6. Sign ...