参考代码:
#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 人评分
简单的a+b (C语言代码)浏览:489 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:661 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:674 |
找出最长的字符串来 (C语言代码)浏览:1762 |
逆反的01串 (C语言代码)浏览:1436 |
小九九 (C语言代码)浏览:500 |
C语言程序设计教程(第三版)课后习题6.11 (C++代码)浏览:508 |
陶陶摘苹果 (C语言代码)浏览:589 |
图形输出 (Java代码)浏览:453 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:350 |