Greatest Common Increasing Subsequence

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3649    Accepted Submission(s): 1147

Problem Description
This is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence.
 
Input
Each sequence is described with M - its length (1 <= M <= 500) and M integer numbers Ai (-2^31 <= Ai < 2^31) - the sequence itself.
 
Output
output 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 <iostream>
#include <cstdio>
#include <cstring>
#define clr(x,y) memset(x,y,sizeof(x))
using namespace std;
int a[],b[],ans[],an,bn;
int work()
{
memset(ans,,sizeof(ans));
int i,j,t,maxa,maxan=;
for(i=; i<=an; i++)
{
maxa=;
for(j=; j<=bn; j++)
{
if(a[i]>b[j]&&ans[j]>maxa)maxa=ans[j];
if(a[i]==b[j]&&ans[j]<maxa+)
ans[j]=maxa+;
}
}
for(i=;i<=bn;i++)
if(ans[i]>maxan)maxan=ans[i];
return maxan;
}
int main()
{
int t,i;
scanf("%d",&t);
while(t--)
{
scanf("%d",&an);
for(i=; i<=an; i++)scanf("%d",&a[i]);
scanf("%d",&bn);
for(i=; i<=bn; i++)scanf("%d",&b[i]);
printf("%d\n",work());
if(t)printf("\n");
}
}
Source

Greatest Common Increasing Subsequence hdu1423的更多相关文章

  1. HDU1423:Greatest Common Increasing Subsequence(LICS)

    Problem Description This is a problem from ZOJ 2432.To make it easyer,you just need output the lengt ...

  2. HDU 1423 Greatest Common Increasing Subsequence LCIS

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

  3. POJ 2127 Greatest Common Increasing Subsequence -- 动态规划

    题目地址:http://poj.org/problem?id=2127 Description You are given two sequences of integer numbers. Writ ...

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

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

  5. ZOJ 2432 Greatest Common Increasing Subsequence(最长公共上升子序列+路径打印)

    Greatest Common Increasing Subsequence 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problem ...

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

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

  7. POJ 2127 Greatest Common Increasing Subsequence

    You are given two sequences of integer numbers. Write a program to determine their common increasing ...

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

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

  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 ...

随机推荐

  1. 关于package.json的理解

    在我们打包项目的时候或者使用node的时候,常常会看到package.json这个文件,里面乱七八糟的一大堆json,开始的时候没注意,以为是使用node或者npm的时候自动创建的,后来自己写demo ...

  2. 【完整资料】TC358779XBG:HDMI转MIPI DSI芯片方案

    TC358779XBG是一颗HDMI1.4转MIPI  DSI带缩放功能的芯片,分辨率1920*1080,封装BGA80.通信方式:IIC,电源3.3/1.8/2.2,应用领域:平板,广告机,VR,显 ...

  3. MVC客户端验证

    引用JS 注意:删除Layout里面默认引用的JQUERY,否则可能引起JS冲突. <link href="~/Content/Site.css" rel="sty ...

  4. mysql:Linux系统下mysql5.6的安装卸载

    1.1. 下载rpm包 要使用yum 安装mysql,需要mysql的yum仓库,先从官网下载适合你系统的仓库 http://dev.mysql.com/downloads/repo/yum/ 我的是 ...

  5. Oracle实现分页查询的SQL语法汇总

    1.无ORDER BY排序的写法.(效率最高) 经过测试,此方法成本最低,只嵌套一层,速度最快!即使查询的数据量再大,也几乎不受影响,速度依然! sql语句如下: ) TABLE_ALIAS ; 2. ...

  6. 浅谈CSS3动画的凌波微步--steps()

    背景 一日敲代码的我,得到一个需求:写一个10秒的倒计时. 用JavaScript定时器麻溜写完之后,恰好同事勇司机接完水.瞟了一眼,然后凑过来说,这个用CSS3也可以写,而且一行JavaScript ...

  7. JS解析JSON 注意事项总结

    0.必须先解析看看,不然看了白看   地址: http://www.bejson.com/ 1.返回的节点内是不是一个json. 如  {id:1,names:"[{name:A},{nam ...

  8. python tornado 实现类禅道系统

    最近楼主加班 喽, 好久没有更新我的博客了,哎,一言难尽,废话我就不说了,来开始上精华. 背景:目前市面上有很多bug管理工具,但是各有各的特点,最著名,最流行的就是禅道,一个偶然的机会接触到了pyt ...

  9. IT之光

    作为一个IT界的新新人才,现在拥有第一个博客,可以在这里学习和分享IT方面的知识和技术.

  10. 201521123075 《Java程序设计》第1周学习总结

    1. 本周学习总结 (1)Java不仅是程序语言,还是一种标准规范,代表着解决问题的方案.Java是一个面向对象的编程语言,熟悉后相对于c++更方便,其一大特色就是能够跨平台运行. (2)Java发展 ...