Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp> // Common file
- #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
- using namespace std;
- using namespace __gnu_pbds;
- typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
- #define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- const int N = 1000;
- int dp[N + 4];
- int n, arr[N + 4], maxLen;
- const int MOD = 1e9 + 7;
- int solve1(int index)
- {
- if(index == n)
- return 1;
- if(dp[index] != -1)
- return dp[index];
- int ans = solve1(index + 1);
- for(int k = index + 1; k < n; k++)
- {
- if(arr[k] > arr[index])
- ans = max(ans, max(1, 1 + solve1(k)));
- }
- return dp[index] = ans;
- }
- int main()
- {
- IO;
- unsigned long long int t;
- cin >> t;
- for(int test = 1; test <= t; test++)
- {
- cin >> n;
- for(int i = 0; i < n; i++)
- cin >> arr[i];
- memset(dp, -1, sizeof dp);
- maxLen = max(maxLen, solve1(0));
- cout << maxLen;
- memset(arr, 0, sizeof arr);
- if(test < t)
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement