zoukankan      html  css  js  c++  java
  • wenbao与LCIS(最长公共上升子序列)

    http://acm.hdu.edu.cn/showproblem.php?pid=5904

     1 #include <iostream>
     2 #include <stdio.h>
     3 using namespace std;
     4 const int maxn = 1e6+10;
     5 const int maxn2 = 1e5+10;
     6 int sum1[maxn], sum2[maxn], c[maxn2], d[maxn2];
     7 int main(){
     8     int t, n, m, x;
     9     scanf("%d", &t);
    10     while(t--){
    11         int ma = 0;
    12         scanf("%d %d", &n, &m);
    13         for(int i = 0; i < n; i++){
    14             scanf("%d", &c[i]);
    15             sum1[c[i]] = sum1[c[i]-1] + 1;
    16         }
    17         for(int i = 0; i < m; i++){
    18             scanf("%d", &d[i]);
    19             sum2[d[i]] = sum2[d[i]-1] + 1;
    20         }
    21         for(int i = 0; i < n; i++) ma = max(ma, min(sum1[c[i]], sum2[c[i]]));
    22         printf("%d
    ", ma);
    23         // memset(sum1, 0, sizeof(sum1));    //too young
    24         // memset(sum2, 0, sizeof(sum2));    //too young
    25         for(int i = 0; i < n; i++) sum1[c[i]] = 0;
    26         for(int j = 0; j < m; j++) sum2[d[j]] = 0;
    27     }
    28     return 0;
    29 }

    只有不断学习才能进步!

  • 相关阅读:
    update(十)
    perl-basic-数据类型&引用
    R-barplot()
    leetcode-22-string
    Java-basic-7-面向对象
    Java-basic-6-方法
    Java-basic-4-数据类型
    Java-basic-3-运算符-修饰符-循环
    Java-basic-2-
    leetcode-21-knapsack
  • 原文地址:https://www.cnblogs.com/wenbao/p/5917624.html
Copyright © 2011-2022 走看看