# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829456 | tolbi | Radio Towers (IOI22_towers) | C++17 | 0 ms | 0 KiB |
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 <vector>
vector<int> arr;
int n;
int st;
void init(int N, std::vector<int> H) {
arr=H;
n=N;
for (int i = 0; i < N; i++){
if (H[i]<H[st]) st=i;
}
}
int max_towers(int L, int R, int D) {
int mava = -23;
int ans = 1;
int nmiva = arr[st];
for (int i = st+1; i < n; i++){
if (mava>=nmiva+D && mava>=arr[i]+D){
mava=-23;
ans++;
nmiva=max(nmiva,arr[i]);
}
else mava=max(mava,arr[i]);
}
mava=-23;
for (int i = st-1; i >= 0; i--){
if (mava>=nmiva+D && mava>=arr[i]+D){
mava=-23;
ans++;
nmiva=max(nmiva,arr[i]);
}
else mava=max(mava,arr[i]);
}
return ans;
}