牛客OI赛制测试赛 E:旅行青蛙

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37960603/article/details/82217488

题目传送门
最长不下降子序列
代码:

#include<bits/stdc++.h>
using namespace std;

const int maxn=30000+100;
const int INF=0x3f3f3f3f;

int main(){

    int n;
    scanf("%d",&n);
    vector<int>G;
    for(int i=1;i<=n+1;i++) G.push_back(INF);
    for(int i=1,val;i<=n;i++){

        scanf("%d",&val);
        *upper_bound(G.begin(),G.end(),val)=val;
    }
    printf("%d\n",lower_bound(G.begin(),G.end(),INF)-G.begin());
}

猜你喜欢

转载自blog.csdn.net/qq_37960603/article/details/82217488