zoukankan      html  css  js  c++  java
  • 挑战练习题2.3动态规划 poj1631 Bridging signals 最长递增子序列

    题目链接:

    http://poj.org/problem?id=1631

    题意:

    直接看样例,题意是啥?

    题解:

    LIS, O(nlogn)的,维护一个数组ans,手动模拟一下就懂了。

    代码:

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <algorithm>
     5 using namespace std;
     6 typedef long long ll;
     7 #define MS(a) memset(a,0,sizeof(a))
     8 #define MP make_pair
     9 #define PB push_back
    10 const int INF = 0x3f3f3f3f;
    11 const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
    12 inline ll read(){
    13     ll x=0,f=1;char ch=getchar();
    14     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    15     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    16     return x*f;
    17 }
    18 //////////////////////////////////////////////////////////////////////////
    19 const int maxn = 1e5+10;
    20 
    21 int a[maxn],ans[maxn];
    22 
    23 int main(){
    24     int T = read();
    25     while(T--){
    26         int n = read();
    27         for(int i=1; i<=n; i++)
    28             a[i] = read();
    29 
    30         memset(ans,0x3f,sizeof(ans));
    31 
    32         int mx = -1;
    33         for(int i=1; i<=n; i++){
    34             int p = lower_bound(ans+1,ans+1+n,a[i])-ans;
    35             ans[p] = a[i];
    36             mx = max(mx,p);
    37         }
    38 
    39         cout << mx << endl;
    40     }
    41 
    42     return 0;
    43 }
  • 相关阅读:
    oracle用户和权限
    oracle中的索引
    oracle中的序列
    oracle中的视图
    oracle PL/SQL块
    oracle创建表案列
    半导体随机存储器
    IEEE754标准
    定点数的移位操作
    真值,原码,反码以及补码和移码总结
  • 原文地址:https://www.cnblogs.com/yxg123123/p/6827613.html
Copyright © 2011-2022 走看看