zoukankan      html  css  js  c++  java
  • poj1631 Bridging signals

    思路:

    LIS,二分。

    实现:

     1 #include <cstdio>
     2 #include <iostream>
     3 using namespace std;
     4 int d[40010];
     5 int fuck(int x, int right)
     6 {
     7     int left = 0;
     8     int pos = -1;
     9     while (left <= right)
    10     {
    11         int middle = (left + right) / 2;
    12         if (d[middle] >= x)
    13         {
    14             pos = middle;
    15             right = middle - 1;
    16         }
    17         else
    18         {
    19             left = middle + 1;
    20         }
    21     }
    22     return pos;
    23 }
    24 int main()
    25 {
    26     int t, n;
    27     int temp;
    28     cin >> t;
    29     while (t--)
    30     {
    31         cin >> n;
    32         int cnt = 0;
    33         for (int i = 0; i < n; i++)
    34         {
    35             scanf("%d", &temp);
    36             if (cnt == 0 || temp > d[cnt - 1])
    37             {
    38                 d[cnt++] = temp;
    39             }
    40             else
    41             {
    42                 int pos = fuck(temp, cnt - 1);
    43                 d[pos] = temp;
    44             }
    45         }
    46         printf("%d
    ", cnt);
    47     }
    48     return 0;
    49 }
  • 相关阅读:
    Java——GUI
    linux变量
    shell脚本
    linux查找文件命令
    composer的安装
    restful的nginx配置方法
    api调用安全
    PHP设置Cookie的HTTPONLY属性
    php的异常处理
    php错误报告
  • 原文地址:https://www.cnblogs.com/wangyiming/p/6576131.html
Copyright © 2011-2022 走看看