1 条题解

  • 1

    #include <iostream>
    #include <algorithm>
    using namespace std;

    int main()
    {
    int a[100001],top=0,n,x;
    cin>>n>>x;
    a[++top]=x;
    for(int i=2;i<=n;++i)
    {
    cin>>x;
    if(x>=a[top])
    a[++top]=x;
    else
    {
    int p=upper_bound(a+1,a+top+1,x)-a;
    a[p]=x;
    }
    }
    cout<<top;
    }//用upper_bound吧,看起来简便一点w

  • 1

信息

ID
1088
难度
5
分类
(无)
标签
递交数
38
已通过
15
通过率
39%
上传者