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.

53 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
int a[1001] = {0};
int f[1001] = {0};
#define INF 0x3f3f3f3f
int main() {
//输入+输出重定向
freopen("../1276.txt", "r", stdin);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
//初始值
int MAX = -INF;
for (int i = 1; i <= n; i++) { //遍历每一个元素
f[i] = 1;
for (int j = 1; j < i; j++) {
if (a[j] > a[i] && f[j] + 1 > f[i]) {
f[i] = f[j] + 1;
}
}
//将最小的dp[i]的值记录到MIN里
MAX = max(MAX, f[i]);
}
//输出MAX
cout << MAX << endl;
/*
//输出dp
for (int i = 1; i < n; i++) {
cout << dp[i] << " ";
}
cout << endl;
*/
//贪心策略从头开始如果发现数字在增长就不管它如果发现一样或者变小了则count++,最后到头时,需要补一个++
int count = 0;
for (int i = 1; i < n; i++) {
if (f[i] >= f[i + 1]) count++;
}
cout << count + 1 << endl;
//关闭文件
fclose(stdin);
return 0;
}