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>
#include <bits/stdc++.h>
using namespace std;
const int INF = 2'000'000'000;
vector<int> H;
int N;
vector<int> comm;
void init(int n, std::vector<int> h) {
H = h;
N = n;
comm = vector<int> (N-1, 0);
for (int i=1; i<(N-1); i++)
{
comm[i] = comm[i-1];
if ((H[i]<H[i-1]) and (H[i]<H[i+1]))
comm[i]++;
}
}
int max_towers(int L, int R, int D) {
if ((R-L)<=1)
return 1;
int ans = comm[R-1]-comm[L+1];
if (H[L] < H[L+1])
ans++;
if (H[R] < H[R-1])
ans++;
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... |