Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- typedef long long ll;
- const int maxn = 2505;
- int n, a[maxn];
- int rec(int at) {
- int res = 1;
- for(int i = at + 1; i < n; i++) {
- if(a[at] < a[i]) {
- res = max(res, rec(i) + 1);
- }
- }
- return res;
- }
- int main() {
- cin >> n;
- for(int i = 0; i < n; i++) {
- cin >> a[i];
- }
- int res = 0;
- for(int i = 0; i < n; i++) {
- res = max(res, rec(i));
- }
- cout << res << endl;
- return 0;
- }
- // 10 9 2 5 3 7 101 18
- // 0 1 0 3 2 3
- // 7 7 7 7 7 7 7
Advertisement
Add Comment
Please, Sign In to add comment