Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int int64_t
- int32_t main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0); cout.tie(0);
- int n;
- cin >> n;
- vector<int> a(n);
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- }
- vector<int> dp(n, 1);
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < i; j++) {
- if (a[j] < a[i]) {
- dp[i] = max(dp[i], dp[j] + 1);
- }
- }
- }
- int ans = 0;
- for (int i = 0; i < n; i++) {
- ans = max(ans, dp[i]);
- }
- cout << ans << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment