LCIS
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1734 Accepted Submission(s): 760

Problem Description
Alex has two sequences a1,a2,…,an and b1,b2,…,bm. He wants find a longest common subsequence that consists of consecutive values in increasing order.

Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:

The first line contains two integers n and m (1≤n,m≤100000) – the length of two sequences. The second line contains n integers: a1,a2,…,an (1≤ai≤106). The third line contains n integers: b1,b2,…,bm (1≤bi≤106).

There are at most 1000 test cases and the sum of n and m does not exceed 2×106.

Output
For each test case, output the length of longest common subsequence that consists of consecutive values in increasing order.

Sample Input
3
3 3
1 2 3
3 2 1
10 5
1 23 2 32 4 3 4 5 6 1
1 2 3 4 5
1 1
2
1

Sample Output
1
5
0

Source
BestCoder Round #87

问题链接:HDU5904 LCIS
问题简述:(略)
问题分析:最长公共上升子序列问题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* HDU5904 LCIS */#include <bits/stdc++.h>using namespace std;const int N = 1e5 + 1;
int a[N], b[N];int main()
{int t, n, m;scanf("%d", &t);while (t--) {memset(a, 0, sizeof a);memset(b, 0, sizeof b);int k, ans = 0;scanf("%d%d", &n, &m);for (int i = 1; i <= n; i++) {scanf("%d", &k);a[k] = max(a[k], a[k - 1] + 1);}for (int i = 1; i <= m; i++) {scanf("%d", &k);b[k] = max(b[k], b[k - 1] + 1);ans = max(ans, min(a[k], b[k]));}printf("%d\n", ans);}return 0;
}

HDU5904 LCIS【LCIS】相关推荐

  1. 【CentOS】利用Kubeadm部署Kubernetes (K8s)

    [CentOS]利用Kubeadm部署Kubernetes (K8s)[阅读时间:约10分钟] 一.概述 二.系统环境&项目介绍 1.系统环境 2.项目的任务要求 三.具体实验流程 1 系统准 ...

  2. 【Spring】框架简介

    [Spring]框架简介 Spring是什么 Spring是分层的Java SE/EE应用full-stack轻量级开源框架,以IOC(Inverse Of Control:反转控制)和AOP(Asp ...

  3. 【C#】类——里式转换

    类是由面对对象程序设计中产生的,在面向结构的程序设计例如C语言中是没有类这个概念的!C语言中有传值调用和传址调用的两种方式!在c语言中,主方法调用方法,通过传递参数等完成一些操作,其中比较常用的的数据 ...

  4. 【C#】Out与ref是干什么的?

    关于return: 1.最后没有写 return 语句的话,表示程序正常退出 2.不需要返回值时,存在return的作用 例子 void main() {return; //return退出该程序的作 ...

  5. 【软件工程】RUP与软件开发5大模型

    软件开发的5大模型 1.瀑布模型:按照人的思维一步一步的开发下去,如果需求分析得当,每个阶段顺利,结果还不错! 2.快速原型模型:后来人们发现,自己不可能一下子就把所有的需求搞清楚,总是在开发的过程中 ...

  6. 【VB】学生信息管理系统5——数据库代码

    这次学生信息管理系统在代码的理解过程中遇到了一些问题.总结如下: 1. sql server的安装过程各个步骤的意思.在安装SQL Server的时候按照网上的步骤,我觉得这个需要学完整个数据库再返回 ...

  7. 白化(预处理步骤)【转】

    白化(预处理步骤)[转] 介绍 我们已经了解了如何使用PCA降低数据维度.在一些算法中还需要一个与之相关的预处理步骤,这个预处理过程称为白化.举例来说,假设训练数据是图像,由于图像中相邻像素之间具有很 ...

  8. 【Tensorflow】tf.nn.atrous_conv2d如何实现空洞卷积?膨胀卷积

    介绍 关于空洞卷积的理论可以查看以下链接,这里我们不详细讲理论: 1.Long J, Shelhamer E, Darrell T, et al. Fully convolutional networ ...

  9. 兑换量子计算机,阅读 | 【量子计算机】构造置换量子门

    原标题:阅读 | [量子计算机]构造置换量子门 量子计算机的一个基本组成单位叫量子门(quantum gate),下面简单介绍些基本概念. 量子比特和量子态 量子计算机的信息存储单元是一种叫做量子比特 ...

最新文章

  1. 关于敏捷开发的最佳实践和工具
  2. jetty9 web app的部署
  3. Linux网络模拟,模拟网络访问解析
  4. 从数学的角度来谈谈,孩子为什么要学编程!
  5. 前端学习(205):animation动画库
  6. python并行计算进程池通信_Python使用进程池管理进程和进程间通信
  7. AndroidStudio_后台_服务的介绍_生命周期_注册_启动停止---Android原生开发工作笔记215
  8. android关于截屏,关于android截屏知识的学习
  9. index merge的数据结构和成本评估
  10. CString类简介
  11. hdu4608 暴力+大数
  12. Mantis1.2.19 在Windows 平台上的安装配置详解
  13. 正二十面体的各个面位置点
  14. 键盘拆开重新安装步骤_键盘拆卸后怎么安装?
  15. Echarts 实现环状半圆形饼图
  16. wifi设备名称android,Android设置WiFi设备名解析
  17. 阿里移动安全陈树华:安全的最高境界是无感知
  18. 自律的程序员生活是什么样的?
  19. labVIEW写入电子表格文件
  20. 大数据技术为什么那么火?

热门文章

  1. 高并发服务器开源项目,高并发服务器框架详解 - osc_qgfjs4a5的个人空间 - OSCHINA - 中文开源技术交流社区...
  2. C# 图片处理之:彩色图片转为黑白图
  3. linux c++ sqlite_SQLite 真的很容易编译 | Linux 中国
  4. Linux基础命令与进阶
  5. springboot yml多环境开发
  6. SQL中 NVL()函数的使用
  7. Hive数据倾斜及处理
  8. python安装selenium报错_新手用Python运行selenium的常见问题
  9. python classmethod 与 staticmethod
  10. android 滑动缩放监听,基于Android的ViewPager动画特效实现页面左右滑动效果(实现缩放...