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;
vector<int> h;
int f[100009], p[100009];
bool used[100009];
void init(int N, std::vector<int> H) {
h = H;
f[0] = 1000000009;
f[N + 1] = 0;
for (int i = 1; i <= N; i++)
{
f[i] = H[i - 1];
}
p[0] = 0;
for (int i = 1; i <= N; i++)
{
p[i] = p[i - 1];
if (f[i - 1] > f[i] && f[i + 1] > f[i])
{
p[i]++;
used[i] = true;
}
}
}
int max_towers(int L, int R, int D) {
L++;
R++;
int ans = p[R] - p[L - 1];
if (!used[L] && f[L - 1] > f[L])
{
ans++;
}
if (L != R && !used[R] && f[R + 1] > f[R])
{
ans++;
}
return max(ans, 1);
}
# | 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... |