题目大意:
http://codevs.cn/problem/1576/
代码:
#include <iostream> using namespace std; int arr[5100] = {0}; int dp[5100] = {0}; int main() { int n,ans = 0;; cin >> n; for(int i = 1; i <= n; i++ ) cin >> arr[i]; dp[0] = 0; for(int i = 1; i <= n; i++) { for(int j = 0; j < i; j++) { if(arr[i] >= arr[j]) dp[i] = max(dp[i],dp[j]+1); ans = max(ans,dp[i]); } } cout << ans; return 0; }