Submission #1047451

#TimeUsernameProblemLanguageResultExecution timeMemory
1047451SN0WM4NRainforest Jumps (APIO21_jumps)C++14
0 / 100
4080 ms3512 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; vector<int> v; vector<int> m_sig; void init(int N, std::vector<int> H) { v = H; m_sig.resize(N); int mx = 1e9, idx = -1; for (int i = N - 1; i >= 0; i --) { m_sig[i] = i; for (int j = i; j < N; j ++) { if (H[j] > H[i]) { m_sig[i] = j; break; } } } } int minimum_jumps(int A, int B, int C, int D) { int mx = -1, idx = -1; for (int i = A; i <= B; i ++) { if (v[i] > mx) { mx = v[i]; idx = i; } } int ans = 0; while (idx < C) { ans ++; if (idx == m_sig[idx]) break; idx = m_sig[idx]; } if (C <= idx && idx <= D) return ans; return -1; }

Compilation message (stderr)

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:13:13: warning: unused variable 'mx' [-Wunused-variable]
   13 |         int mx = 1e9, idx = -1;
      |             ^~
jumps.cpp:13:23: warning: unused variable 'idx' [-Wunused-variable]
   13 |         int mx = 1e9, idx = -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...