Advertisement
Ginger_samurai

Untitled

Feb 3rd, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <cmath>
  7. #include<set>
  8. #include<math.h>
  9. using namespace std;
  10.  
  11.  
  12.  
  13.  
  14. int main() {
  15.     int n;
  16.     cin >> n;
  17.  
  18.     vector<int>v(n);
  19.  
  20.     for (int i = 0; i < n; i++) {
  21.         cin >> v[i];
  22.     }
  23.  
  24.  
  25.     vector<int>dp(n);
  26.     dp[0] = 1;
  27.     int res = 1;
  28.     for (int i = 1; i < n; i++) {
  29.         dp[i] = 1;
  30.         for (int j = 0; j < i; j++) {
  31.             if (v[i] > v[j]) {
  32.                 dp[i] = max(dp[i], dp[j] + 1);
  33.             }
  34.         }
  35.         res = max(res, dp[i]);
  36.     }
  37.     cout << res;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement