rembocoder

Untitled

May 14th, 2023
1,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int int64_t
  6.  
  7. int32_t main() {
  8.     ios_base::sync_with_stdio(false);
  9.     cin.tie(0); cout.tie(0);
  10.     int n;
  11.     cin >> n;
  12.     vector<int> a(n);
  13.     for (int i = 0; i < n; i++) {
  14.         cin >> a[i];
  15.     }
  16.     vector<int> dp(n, 1);
  17.     for (int i = 0; i < n; i++) {
  18.         for (int j = 0; j < i; j++) {
  19.             if (a[j] < a[i]) {
  20.                 dp[i] = max(dp[i], dp[j] + 1);
  21.             }
  22.         }
  23.     }
  24.     int ans = 0;
  25.     for (int i = 0; i < n; i++) {
  26.         ans = max(ans, dp[i]);
  27.     }
  28.     cout << ans << '\n';
  29. }
Advertisement
Add Comment
Please, Sign In to add comment