思路:倒序查找,默认系统数为1,遇到递增就+1;
dp[i] = dp[j] + 1;
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> arr, dp(1000, 0);
int cnt = 1, maxnum = 0;
void solve(int i)
{
if (i < 0) return;
if (i != 0 && arr[i - 1] < arr[i]) cnt++;
if (i == arr.size() - 1) dp[i] = 1;
else
{
for (int j = i + 1; j < arr.size(); j++)
{
if (arr[i] > arr[j])
dp[i] = max(dp[i], dp[j]);
}
dp[i]++;
}
maxnum = max(dp[i], maxnum);
solve(i - 1);
}
int main()
{
int num;
while (cin >> num)
{
arr.push_back(num);
}
solve(arr.size() - 1);
cout << maxnum << endl;
cout << cnt << endl;
system("pause");
return 0;
}