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 <bits/stdc++.h>
using namespace std;
#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]);
}
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]);
}
mava=max(mava,arr[i]);
}
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... |