LCIS

 /* 1423 */
#include <cstdio>
#include <cstring>
#include <cstdlib> #define MAXN 505 int a[MAXN];
int b[MAXN];
int c[MAXN];
int n, m;
int ans; int max(int a, int b) {
return a>b ? a:b;
} void solve() {
int i, j, k; memset(c, , sizeof(c));
for (i=; i<n; ++i) {
k = ;
for (j=; j<m; ++j) {
if (a[i] == b[j]) {
c[j] = max(c[j], k+);
}
if (a[i] > b[j]) {
k = max(k, c[j]);
}
}
}
ans = -;
for (i=; i<m; ++i)
ans = max(ans, c[i]);
} int main() {
int t;
int i, j, k; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (i=; i<n; ++i)
scanf("%d", &a[i]);
scanf("%d", &m);
for (i=; i<m; ++i)
scanf("%d", &b[i]);
solve();
printf("%d\n", ans);
if (t)
printf("\n");
} return ;
}

【HDOJ】1423 Greatest Common Increasing Subsequence的更多相关文章

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

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

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

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

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

  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. HDU 1423 Greatest Common Increasing Subsequence LCIS

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

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

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

  7. HDU 1423 Greatest Common Increasing Subsequence(LCIS)

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

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

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

  9. HDOJ 1423 Greatest Common Increasing Subsequence(dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1423 思路分析:[问题定义]给定两个序列A[0, 1,..., m]和B[0, 1, ..., n], ...

随机推荐

  1. android scrollview组件禁止滑动的方法

    xml配置:           android:id="@+id/sc_freement"             android:layout_width="fill ...

  2. [Javascript] Advanced Console Log Arguments

    Get more mileage from your console output by going beyond mere string logging - log entire introspec ...

  3. 对话框 自定义 IOS风格 包青天

    activity     private void showDialog1() {         message = "您输入的邮箱后缀不是公司邮箱地址\n将导致您的借款审核不通过,请重新 ...

  4. poj 1125 Stockbroker Grapevine (dij优化 0ms)

    #include<iostream> #include<cstdio> #include<cstring> #include<queue> #defin ...

  5. INSTALL_PARSE_FAILED_MANIFEST_MALFORMED 错误

    在eclipse编译好文件之后,往AVD中安装apk,报错如下:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED一般来说只需要检查AndroidManifest.xml中 ...

  6. Linq101-Restriction

    using System; using System.Linq; namespace Linq101 { class Restriction { /// <summary> /// Thi ...

  7. Struts1 中实现Action跳转地址栏变化的方法

    Action进行跳转,有时候地址栏不变化,如果重复刷新就会重复提交, 这里一般需要进行重定向: 1.在xml里面进行配置 <action path="/checkCdconfirmEn ...

  8. WorkBook的SaveAs方法 2

    -----转载:http://blog.csdn.net/zyming0815/article/details/5939104 语法 声明Sub SaveAs ( _     Filename As ...

  9. 05DotNet基本常用类库

    1.String成员方法(常用) bool Contains(String str);判断字符串对象是否包含给定的字符串; bool StartsWith(String str);判断字符串对象是否以 ...

  10. css实现鼠标移入table时出现滚动条且table内容不移位

    一般是这样: 表格的标题和内容分别由一个table组成,其中表格内容的table由一个class="table-body"的div包裹.css如下 .tContainer .tab ...