# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
569016 | kikoki | Rainforest Jumps (APIO21_jumps) | C++17 | 0 ms | 0 KiB |
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 "jumps.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> a;
void init(int N, vector<int> H)
{
n = N;
a = H;
}
ll minimum_jumps(int A, int B, int C, int D)
{
ll cnt = 0, cur = A;
if (A < C)
{
for (ll i = A; i <= C; i++)
{
if (a[cur] >= a[C])
{
return -1;
}
if (a[cur] < a[i])
{
cur = i;
cnt++;
}
}
return cnt;
}
else
{
for (ll i = A; i >= C; i--)
{
if (a[cur] >= a[C])
{
return -1;
}
if (a[cur] < a[i])
{
cur = i;
cnt++;
}
}
return cnt;
}
return -1;
}