#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
#define chmax(a, b) a = max(a, b)
#define pb push_back
const int maxn = 1e5 + 4;
int n;
int h[maxn];
int dp[maxn];
int pre[maxn];
int local_min(int i) {
	if (1 <= i-1 && h[i] > h[i-1]) return 0;
	if (i+1 <= n && h[i] > h[i+1]) return 0;
	return 1;
}
void init(int N, std::vector<int> H) {
	n = N;
	for (int i=1; i<=n; i++) h[i] = H[i];
	for (int i=1; i<=n; i++) pre[i] = pre[i-1] + local_min(i);
}
int max_towers(int L, int R, int D) {
	if (L==R) return 1;
	L++; R++;
	int ans = pre[R] - pre[L-1];
	ans -= local_min(L);
	ans -= local_min(R);
	ans += (h[L] < h[L+1]);
	ans += (h[R] < h[R-1]);
	ans++;
	chmax(ans, 1);
	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... |