/**
_ _ __ _ _ _ _ _ _
|a ||t ||o d | |o |
| __ _| | _ | __| _ |
| __ |/_ | __ /__\ / _\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N_MAX = 100000;
int N;
int H[N_MAX];
void init (int _N, int _H[]) {
N = _N;
copy(_H, _H + N, H);
}
int max_towers (int L, int R, int D) {
if (L > R) {
return 0;
}
if (L == R) {
return 1;
}
int K = L;
for (int i = L + 1; i <= R; i++) {
if (H[i] > H[K]) {
K = i;
}
}
int mnL = INT_MAX, mnR = INT_MAX;
for (int i = L; i < K; i++) {
mnL = min(mnL, H[i]);
}
for (int i = R; i > K; i--) {
mnR = min(mnR, H[i]);
}
int mxtL = max_towers(L, K - 1, D);
int mxtR = max_towers(K + 1, R, D);
return (mnL <= H[K] - D && mnR <= H[K] - D ? mxtL + mxtR : max(mxtL, mxtR));
}
Compilation message
/usr/bin/ld: /tmp/ccDehlYW.o: in function `main':
stub.cpp:(.text.startup+0x179): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status