#include "towers.h"
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<ll,ll> pii;
typedef pair<ll,pii> ipii;
const int MAXN = 3e5+100;
const int LOG = 19;
const ll INF = 2e18+10;
void chmx(auto &a, auto b){ a = max(a, b); }
void chmn(auto &a, auto b){ a = min(a, b); }
int n, h[MAXN], st[MAXN][LOG+5];
int idx, LE, RI;
void init(int N, std::vector<int> H) {
n = N;
for(int i=1; i<=n; i++){
h[i] = H[i-1];
st[i][0] = h[i];
}
for(int i=2; i+1<=n; i++){
if(h[i] > h[i-1] && h[i] > h[i+1]){
idx = i; // ini idxnya
}
}
for(int j=1; j<LOG; j++){
for(int i=1; i+(1<<j)-1<=n; i++){
st[i][j] = max(st[i][j-1], st[i+(1<<(j-1))][j-1]);
}
}
}
int dp[MAXN];
int max_towers(int L, int R, int D) {
int l = L+1, r = R+1, d = D;
if(idx <= l) return 1;
if(r <= idx) return 1;
int ANS = 1;
if(max(h[l], h[r]) <= h[idx]-d) ANS = 2;
return ANS;
}
# | 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... |