|
|
|
@ -149,32 +149,32 @@ int main() {
|
|
|
|
|
fl = 0, gl = 0;
|
|
|
|
|
|
|
|
|
|
cin >> n;
|
|
|
|
|
for (int i = 1; i <= n; i++) cin >> a[i];
|
|
|
|
|
for (int i = 0; i < n; i++) cin >> a[i];
|
|
|
|
|
|
|
|
|
|
// 正着求
|
|
|
|
|
f[++fl] = a[1];
|
|
|
|
|
for (int i = 2; i <= n; i++) {
|
|
|
|
|
f[0] = a[0];
|
|
|
|
|
for (int i = 1; i < n; i++) {
|
|
|
|
|
if (a[i] > f[fl])
|
|
|
|
|
f[++fl] = a[i];
|
|
|
|
|
else
|
|
|
|
|
*lower_bound(f + 1, f + 1 + fl, a[i]) = a[i];
|
|
|
|
|
*lower_bound(f, f + fl, a[i]) = a[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 前半程的结果
|
|
|
|
|
res = fl;
|
|
|
|
|
|
|
|
|
|
// 反着求
|
|
|
|
|
g[++gl] = a[n];
|
|
|
|
|
for (int i = n - 1; i >= 1; i--) {
|
|
|
|
|
g[0] = a[n-1];
|
|
|
|
|
for (int i = n - 1; i >= 0; i--) {
|
|
|
|
|
if (a[i] > g[gl])
|
|
|
|
|
g[++gl] = a[i];
|
|
|
|
|
else
|
|
|
|
|
*lower_bound(g + 1, g + 1 + gl, a[i]) = a[i];
|
|
|
|
|
*lower_bound(g, g + gl, a[i]) = a[i];
|
|
|
|
|
}
|
|
|
|
|
// pk的最大结果
|
|
|
|
|
res = max(res, gl);
|
|
|
|
|
// 输出
|
|
|
|
|
printf("%d\n", res);
|
|
|
|
|
printf("%d\n", res + 1);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|