Untitled
unknown
plain_text
a year ago
999 B
4
Indexable
#include <bits/stdc++.h> using namespace std; #define endl '\n' #ifndef ONLINE_JUDGE #include "debug.h" #else #define deb(x...) #endif vector<int> dp; int n; vector<int> a; map<vector<int>, int> m; vector<int> vv; int rec(int level) { if (level == -1) { return 0; } if (dp[level] != -1e9) { return dp[level]; } int ans = 1; for (int i = 0; i < level; i++) { if (a[i] < a[level]) { ans = max(ans, 1 + rec(i)); } } return dp[level] = ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while(tt--) { cin >> n; dp.resize(n, -1e9); a.resize(n); for (int i = 0; i < n; i++) { cin >> a[i]; } rec(n - 1); int ans = 0; for (int i = 0; i < n; i++) { ans = max(ans, rec(i)); } deb(dp); } return 0; }
Editor is loading...
Leave a Comment