Ginger_samurai

Untitled

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