Submission #1020303

#TimeUsernameProblemLanguageResultExecution timeMemory
1020303MohamedFaresNebiliRainforest Jumps (APIO21_jumps)C++14
0 / 100
320 ms65064 KiB
#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]; int cur = 0; for(int i = l + 1; i < _N; i++) { if(_H[i] > lst) R[l][i] = ++cur; else R[l][i] = 1e9 + 7; lst = max(lst, _H[i]); } L[l][l] = 0, lst = _H[l]; cur = 0; for(int i = l - 1; i >= 0; i--) { if(_H[i] > lst) L[l][i] = ++cur; else L[l][i] = 1e9 + 7; lst = max(lst, _H[i]); } } } int minimum_jumps(int A, int B, int C, int D) { int res = 1e9 + 7; for(int l = A; l <= B; l++) { for(int i = C; i <= D; i++) { for(int j = l; j >= 0; j--) { res = min(res, L[l][j] + R[j][i]); } } } return (res == 1e9 + 7 ? -1 : res); }
#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...