#include "jumps.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int n, L[200001], R[200001], dp[200001];
vector<int> g[200001];
void init(int N, std::vector<int> H) {
n = N;
stack<int> st;
//for (int i = 0; i < N; i++) {
//while (st.size() && H[st.top()] <= H[i]) st.pop();
//if (st.size()) L[i] = st.top();
//else L[i] = -1;
//st.push(i);
//}
for (int i = N - 1; i >= 0; i--) {
while (st.size() && H[st.top()] <= H[i]) st.pop();
if (st.size()) R[i] = st.top();
else R[i] = -1;
st.push(i);
}
}
int minimum_jumps(int A, int B, int C, int D) {
int ans = 1e9;
for (int i = A; i <= B; i++) {
for (int j = i + 1; j < n; j++) dp[j] = 1e9;
dp[i] = 0;
for (int j = i; j < n; j++) {
if (R[j] != -1) dp[R[j]] = min(dp[R[j]], dp[j] + 1);
}
for (int j = C; j <= D; j++) ans = min(ans, dp[j]);
}
return (ans < 1e9 ? ans : -1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Execution timed out |
4013 ms |
8684 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6744 KB |
Output is correct |
5 |
Correct |
2 ms |
6744 KB |
Output is correct |
6 |
Incorrect |
5 ms |
6744 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6744 KB |
Output is correct |
5 |
Correct |
2 ms |
6744 KB |
Output is correct |
6 |
Incorrect |
5 ms |
6744 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6744 KB |
Output is correct |
5 |
Execution timed out |
4035 ms |
8044 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Incorrect |
2248 ms |
7636 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Incorrect |
2248 ms |
7636 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Execution timed out |
4013 ms |
8684 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |