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;
#include "towers.h"
#define pb push_back
#define ll long long
#define fi first
#define se second
const int nax=1e5+5;
int n;
vector<int> tab;
int pre[nax];
void init(int N, std::vector<int> H) {
n=N;
for (int i = 0; i < N; ++i)
{
tab.pb(H[i]);
}
for (int i = 1; i < n-1; ++i)
{
if(tab[i]<=tab[i-1]&&tab[i]<=tab[i+1]) pre[i]=1;
pre[i]+=pre[i-1];
}
pre[n-1]+=pre[n-2];
}
int max_towers(int L, int R, int D){
if(R-L+1<=2) return 1;
return pre[R-1]-pre[L]+(tab[L]<=tab[L+1])+(tab[R]<=tab[R-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... |