29 lines
588 B
C++
29 lines
588 B
C++
#include <iostream>
|
|
using namespace std;
|
|
#define MAXN 10005
|
|
#define M 200
|
|
int dp[MAXN];
|
|
int arr[M];
|
|
int longest_decreasing_subsequence(int n) {
|
|
int maximun = 0;
|
|
for (int i = 0; i < n; i++) {
|
|
dp[i]++;
|
|
for (int j = 0; j < i; j++) {
|
|
if (arr[j] > arr[i]) // 最大上升为 `arr[j] < arr[i]`
|
|
dp[i] = max(dp[i], dp[j] + 1);
|
|
}
|
|
if (dp[i] > maximun)
|
|
maximun = dp[i];
|
|
}
|
|
return maximun;
|
|
}
|
|
int main() {
|
|
int N;
|
|
cin >> N;
|
|
for (int i = 0; i < N; i++) {
|
|
cin >> arr[i];
|
|
}
|
|
int value = longest_decreasing_subsequence(N);
|
|
cout << value << endl;
|
|
}
|