参考代码:
#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语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:1066 |
人见人爱A+B (C语言代码)浏览:625 |
数组输出 (C语言代码)错误???浏览:558 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:594 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:685 |
C二级辅导-计负均正 (C语言代码)浏览:480 |
整除的尾数 (C语言代码)浏览:809 |
A+B for Input-Output Practice (II) (C语言代码)浏览:595 |
三进制小数 (C语言代码)浏览:812 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:529 |