zoukankan      html  css  js  c++  java
  • hdu5773_lis最长上升子序列

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

    题意:给你一个数组,0可以改成任意数,不要求每个0都改成一样的,问改变后的最长上升子序列的长度,不要求连续

     1 #include <algorithm>
     2 #include <iostream>
     3 #include <cstring>
     4 #include <cstdlib>
     5 #include <cstdio>
     6 #include <vector>
     7 #include <ctime>
     8 #include <queue>
     9 #include <list>
    10 #include <set>
    11 #include <map>
    12 using namespace std;
    13 #define INF 0x3f3f3f3f
    14 typedef long long LL;
    15 
    16 int x[100010];
    17 int main()
    18 {
    19     int t, n;
    20     scanf("%d", &t);
    21     for(int i = 1; i <= t; i++)
    22     {
    23         scanf("%d", &n);
    24         int te, num = 0, k = 0;
    25         for(int j = 1; j <= n; j++)
    26         {
    27             scanf("%d", &te);
    28             if(te == 0)
    29             {
    30                 num++;                
    31             }
    32             else
    33             {
    34                 te -= num;
    35                 if(k == 0)
    36                     x[k++] = te;
    37                 else{
    38                     if(te > x[k - 1])
    39                         x[k++] = te;
    40                     else{
    41                         int l1 = lower_bound(x, x + k, te) - x;
    42                         x[l1] = te;
    43                     }
    44                 }
    45             }
    46         }
    47         printf("Case #%d: %d
    ", i, k + num);
    48     }
    49     return 0;
    50 }
  • 相关阅读:
    参考资料来自 懒兔子 的公众号
    Etcd
    zookeeper 杂记
    十二五
    防火墙
    APScheduler
    docker管理工具protainer
    java学习笔记
    linux学习笔记1
    [POI2007]ZAP-Queries
  • 原文地址:https://www.cnblogs.com/luomi/p/5726400.html
Copyright © 2011-2022 走看看