#include "mountains.h"
#include <bits/stdc++.h>
using namespace std;
int maximum_deevs(vector<int> y) {
int N = (int)y.size();
vector<int> memo(N, 0);
memo[N-1] = 1;
int best = 0;
int hi;
for(int i=N-2; i>=0; i--){
best = 0;
hi = y[i+1];
for(int j=i+2; j<N; j++){
//cout << i << " " << j << " " << hi << " " << y[i] << endl;
if(y[j] < hi || (hi > y[i] && y[j] <= hi)) //non lo vede
best = max(best, memo[j]);
hi = max(hi, y[j]);
}
memo[i] = best+1;
}
return *max_element(memo.begin(), memo.end());
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
636 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
636 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
636 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
636 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |