HzuWHF


私信TA

用户名:I7I08I9047

访问量:76406

签 名:

我RUN了

等  级
排  名 18
经  验 20453
参赛次数 13
文章发表 127
年  龄 3
在职情况 学生
学  校 贺州学院
专  业

  自我简介:



参考代码:

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

const int SIZE = 100123;
int datas[SIZE];
int dis[SIZE], Len = 1;
int ups[SIZE], Ind = 1;

struct cmp { 
    bool operator() (int A, int B) { 
        return A > B; 
    } 
};

int main() {
    int pos;
    for (pos = 1; ~scanf("%d", &datas[pos]); pos++);
    ups[1] = dis[1] = datas[1];
    for (int now = 2; now < pos; now++) {
        if (datas[now] <= dis[Len])
            dis[++Len] = datas[now];
        else
            dis[upper_bound(dis + 1, dis + Len + 1, datas[now], cmp()) - dis] = datas[now];
        if (datas[now] > ups[Ind])
            ups[++Ind] = datas[now];
        else
            ups[lower_bound(ups + 1, ups + Ind + 1, datas[now]) - ups] = datas[now];
    }
    printf("%d\n%d\n", Len, Ind);
}


 

0.0分

5 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区