Files
python/TangDou/XiTi/1276.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

53 lines
1.2 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}