参考代码:
#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语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:633 |
母牛的故事 (C语言代码)浏览:1428 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:541 |
数组输出 (C语言代码)浏览:703 |
简单的a+b (C语言代码)浏览:416 |
矩阵转置 (C语言代码)浏览:783 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:478 |
C语言训练-排序问题<1> (C语言代码)浏览:355 |
【计算球体积】 (C语言代码)浏览:1552 |
C语言训练-最大数问题 (C语言代码)浏览:591 |