单调递增最长子序列

和解拦截导弹那题是一样一样的哦,给你一个序列 求出这个序列中最长的单调递增序列,

 1 #include <stdio.h>
 2 #include <string.h>
 3 
 4 #define N 10005
 5 char ch[N];
 6 char dp[N];
 7 
 8 int main()
 9 {
10     int T;
11     scanf("%d",&T);
12     while(T--)
13     {
14         int c = 1;
15         int i = 0;
16         int j = 0;
17         scanf("%s",ch);
18         dp[0] = ch[0];
19         for(i = 1; i < strlen(ch);i++)
20         {
21             for(j = c-1; j >= 0; j--)
22              if(dp[j] < ch[i]) break;
23              dp[j+1] = ch[i];
24 
25              if(j == c-1 ) c++;
26         }
27         printf("%d\n",c);
28     }
29     return 0;
30 }

 


 
                    
            
                

相关文章:

  • 2021-11-21
  • 2021-11-08
  • 2021-11-13
  • 2022-02-18
  • 2022-12-23
  • 2021-07-12
猜你喜欢
  • 2022-01-13
  • 2022-12-23
  • 2021-08-29
  • 2021-12-23
相关资源
相似解决方案