You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
646 B

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a[N];
int f[N], fl;
int g[N], gl;
int main() {
while (cin >> a[n]) n++;
for (int i = 0; i < n; i++) {
f[i] = 1, g[i] = 1;
for (int j = 0; j < i; j++) {
if (a[i] <= a[j])
f[i] = max(f[i], f[j] + 1); // 最长的不上升子序列长度
else
g[i] = max(g[i], g[j] + 1); // 最长单调上升子序列的长度,等于,不上升子序列的覆盖数
}
fl = max(fl, f[i]), gl = max(gl, g[i]);
}
printf("%d\n%d\n", fl, gl);
return 0;
}