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 "towers.h"
#include <bits/stdc++.h>
using namespace std;
using mim = pair<pair<int,int>,int>;
const int maxn=1e5+10;
const int logg=18;
int n;
int h[maxn];
int pref[maxn];
void init(int _n, vector<int> _h) {
n=_n;
for(int i=0;i<n;i++) h[i]=_h[i];
for(int i=1;i<n-1;i++){
pref[i]=pref[i-1];
if(h[i]<h[i+1] && h[i]<h[i-1]) pref[i]++;
}
}
int max_towers(int l, int r, int d) {
int ret=int(l==r);
if(l+1<=r-1) ret+=pref[r-1]-pref[l];
if(r-l>0 && h[l]<h[l+1]) ret++;
if(r-l>0 && h[r]<h[r-1]) ret++;
return ret;
}
# | 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... |