栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

Bubble Sort Graph

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Bubble Sort Graph

题目意思让你找一个最长的升序子序列

#include"bits/stdc++.h"
#define ll long long
#define pi pair
#define inf 0x3f3f3f3f
#define  _for(i,a,b) for(int i=a;i<=b;i++)
#define  for_(i,a,b) for(int i=a;i=b;i--)
#define fr_(i,a,b) for(int i=a;i>b;i--)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int N = 1e5+5;
const ll mod = 1e9+7;
const double lp=1.000000011;
mapmp;
int n,x;
int a[N],b[N],c[N];
void solve(){
    cin >> n;
    _for(i,1,n) cin >> a[i];
    _for(i,1,n) b[i]=inf;
    _for(i,1,n){
        int k = lower_bound(b+1,b+1+n,a[i])-b;
        c[i]=k;
        b[k]=a[i];
    }
    int ans = -inf;
    _for(i,1,n){
        ans = max(ans,c[i]);
    }
    cout << ans << endl;

}

int main()
{
    IOS;
    solve();
    return 0;
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/739298.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号