参考代码:
#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 人评分
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:862 |
罗列完美数 (C语言代码)浏览:491 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:530 |
永远的丰碑 (C语言代码)浏览:520 |
计算质因子 (C语言代码)浏览:704 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:528 |
A+B for Input-Output Practice (I) (C语言代码)浏览:574 |
快速排序算法1浏览:884 |
C语言程序设计教程(第三版)课后习题10.1 (C++代码)浏览:497 |
蓝桥杯基础练习VIP-报时助手 (C++代码)浏览:1064 |