首页 > 其他分享 >HDU 1423

HDU 1423

时间:2023-08-15 17:33:49浏览次数:32  
标签:HDU Java int 1423 length MAXN Input include


Greatest Common Increasing Subsequence

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

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 <stdio.h>
#include <string.h>
const int MAXN=510;
int a[MAXN],b[MAXN];
int f[MAXN];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        memset(f,0,sizeof(f));
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i]);
        int m;
        scanf("%d",&m);
        for(int i=1;i<=m;i++)
            scanf("%d",&b[i]);
        for(int i=1;i<=n;i++)
        {
            int MAX=0;
            for(int k=1;k<=m;k++)
            {
                if(a[i]>b[k]&&MAX<f[k])
                    MAX=f[k];
                if(a[i]==b[k])
                    f[k]=MAX+1;
            }
        }
        int temp=0;
        for(int i=1;i<=m;i++)
        {
            if(temp<f[i])
                temp=f[i];
        }
        printf("%d\n",temp);
        if(t)printf("\n");
    }
    return 0;
}




标签:HDU,Java,int,1423,length,MAXN,Input,include
From: https://blog.51cto.com/u_3936220/7091416

相关文章

  • HDU 1025
    ConstructingRoadsInJGShining'sKingdomTimeLimit:2000/1000MS(Java/Others)  MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):19340  AcceptedSubmission(s):5473ProblemDescriptionJGShining'skingdomconsistsof2n(nis......
  • HDU 1950
    BridgingsignalsTimeLimit:5000/1000MS(Java/Others)  MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):1169  AcceptedSubmission(s):767ProblemDescription'Ohno,they'vedoneitagain',criesthechiefdesigneratth......
  • HDU 1087 (LIS)
    SuperJumping!Jumping!Jumping!TimeLimit:2000/1000MS(Java/Others)  MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):28091  AcceptedSubmission(s):12529ProblemDescriptionNowadays,akindofchessgamecalled“SuperJumping!Jump......
  • HDU 3478
    CatchTimeLimit:2000/1000MS(Java/Others)  MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):1389  AcceptedSubmission(s):682ProblemDescriptionAthiefisrunningaway!Wecanconsiderthecitywherehelocatesasanundirectedgrap......
  • HDU 5364
    DistributionmoneyTimeLimit:2000/1000MS(Java/Others)  MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):310  AcceptedSubmission(s):186ProblemDescriptionAFAwanttodistributionhermoneytosomebody.Shedividehermoneyintons......
  • HDU 5366
    ThemookjongTimeLimit:2000/1000MS(Java/Others)  MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):326  AcceptedSubmission(s):252ProblemDescription![](../../data/images/C613-1001-1.jpg)ZJiaQwanttobecomeastrongman,sohed......
  • HDU 2444
    TheAccomodationofStudentsTimeLimit:5000/1000MS(Java/Others)  MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):3561  AcceptedSubmission(s):1656ProblemDescriptionThereareagroupofstudents.Someofthemmayknoweachother,......
  • HDU 1698(线段树 区间更新)
    JustaHookTimeLimit:4000/2000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):23481    AcceptedSubmission(s):11758ProblemDescriptionInthegameofDotA,Pudge’smeathookisactuallythemosthorr......
  • HDU 3829 Cat VS Dog 猫和狗(二分图)结题报告
    听学长说这道题很ex,但是思路想到的话还是挺简单的。可能是受上一道题(放置机器人)的启发,也是找互相冲突的点连线。但是并不是完全一样(废话)放置机器人那道题是找到冲突点连线后直接求最大匹配即可。这道题稍微把思路变换一下,求出最大完美匹配数\(n\)后,说明有\(n*2\)个人的喜好......
  • HDU7326 string magic(Easy Version)
    HDU7326stringmagic(EasyVersion)tag:回文自动机题目链接题意:多组样例,每组输入一字符串(长度1e5以内),输出满足下列条件的子串个数:该串由两个完全相同的回文串拼接而成做法:字符串的题目一般都比较板,洛谷的P4287可以说是这道题目的原题,我们先看看原题是怎么做的P4287双......