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 <algorithm>
#include <vector>
#include <iostream>
#define ll int
#define ff first
#define ss second
#define ln "\n"
using namespace std;
vector<ll> pref, a;
ll n;
vector<bool> big(n);
void init(int N, std::vector<int> H) {
a=H;
n=N;
pref.clear(); pref.resize(n);
big.clear(); big.resize(n);
for (ll i=1; i<n; i++){
pref[i]=pref[i-1];
if (i+1<n and i-1>=0 and a[i]>a[i-1] and a[i]>a[i+1]) pref[i]++;
}
}
// smallt ->
// bigt ->
int max_towers(int L, int R, int D) {
return max(1, (R-1>=0?pref[R-1]:0)-pref[L]+1);
}
# | 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... |