题解 | #Redraiment的走法#
Redraiment的走法
https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa
#include <iostream> #include <vector> // dp[i]表示以 A[i]作为末尾的最长递增子序列的长度 int arr[201]; int dp[201]; using namespace std; int main() { int n; while (cin >> n) { for (int i = 0; i < n; ++i) { cin >> arr[i]; } int maxN = 0; for (int i = 0; i < n; ++i) { dp[i] = 1; for (int j = 0; j < n; ++j) { if (arr[j] < arr[i]) { dp[i] = max(dp[i], dp[j] + 1); } } maxN = max(maxN, dp[i]); } cout << maxN << endl; } return 0; }