This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int N;
int L[2005][2005], R[2005][2005];
vector<int> H;
void init(int _N, vector<int> _H) {
N = _N;
for(int l = 0; l < _N; l++)
H.push_back(_H[l]);
for(int l = 0; l < _N; l++) {
R[l][l] = 0; int lst = _H[l];
for(int i = l + 1; i < _N; i++) {
R[l][i] = R[l][i - 1] + (_H[i] > lst);
lst = _H[i];
}
L[l][l] = 0, lst = _H[l];
for(int i = l - 1; i >= 0; i--) {
L[l][i] = L[l][i + 1] + (_H[i] > lst);
lst = _H[i];
}
}
}
int minimum_jumps(int A, int B, int C, int D) {
int res = -1;
for(int l = A; l <= B; l++) {
for(int i = C; i <= D; i++) {
for(int j = l; j >= 0; j--) {
if(H[l] <= H[j] && H[j] <= H[i]) {
res = (res == -1 ? L[l][j] + R[j][i] : max(res, L[l][j] + R[j][i]));
}
}
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |