Submission #982523

#TimeUsernameProblemLanguageResultExecution timeMemory
982523vjudge1Rainforest Jumps (APIO21_jumps)C++17
0 / 100
4035 ms8684 KiB
#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); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...