1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include <iostream> #include <algorithm> using namespace std; int arr[1001]; int dp[1001]; int main() { int N; int MAX = 0; cin >> N; for (int i = 1; i <= N; i++) { cin >> arr[i]; int temp = 0; for (int j = 1; j < i; j++) { if (arr[j] > arr[i]) { temp = max(temp, dp[j]); } } dp[i] = temp + 1; MAX = max(dp[i], MAX); } cout << MAX; } | cs |