# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963612 | socpite | Rainforest Jumps (APIO21_jumps) | C++14 | 786 ms | 46680 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<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
const int lg = 18;
int n;
int sp_left[lg][maxn], sp_both[lg][maxn], sp_right[lg][maxn];
int l[maxn], r[maxn];
void init(int N, vector<int> H){
n = N;
stack<int> stk;
for(int i = 0; i < N; i++){
while(!stk.empty() && H[stk.top()] < H[i])stk.pop();
if(stk.empty())l[i] = sp_left[0][i] = -1;
else l[i] = sp_left[0][i] = stk.top();
stk.push(i);
}
while(!stk.empty())stk.pop();
for(int i = N-1; i >= 0; i--){
while(!stk.empty() && H[stk.top()] < H[i])stk.pop();
if(stk.empty())r[i] = sp_right[0][i] = N;
else r[i] = sp_right[0][i] = stk.top();
stk.push(i);
if(l[i] == -1 && r[i] == N)sp_both[0][i] = -1;
else if(l[i] == -1 || (r[i] != N && H[r[i]] > H[l[i]]))sp_both[0][i] = r[i];
else sp_both[0][i] = l[i];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |