Advertisement
Ginger_samurai

Untitled

Feb 9th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1.  
  2. #include<iostream>
  3. #include<vector>
  4. #include<algorithm>
  5. using namespace std;
  6. int main() {
  7.     int n;
  8.     cin >> n;
  9.     vector<int>a(n), dp(n);
  10.     int ans = 0;
  11.     for (int i = 0; i < n; i++) {
  12.         cin >> a[i];
  13.     }
  14.     for (int i = 0; i < n; i++) {
  15.         dp[i] = 1;
  16.         for (int j = 0; j < i; j++) {
  17.             if (a[j] < a[i]) {
  18.                 dp[i] = max(dp[i], dp[j] + 1);
  19.                
  20.                 ans = max(ans, dp[i]);
  21.             }
  22.         }
  23.     }
  24.     cout << ans;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement