이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> H;
void init(int _N, std::vector<int> _H) {
n = _N;
H = _H;
}
int f(int l, int r, int D, int maxHeight) {
int highest = -1;
int count = 0;
for(int i = l; i < r; i++) {
if (H[i] > maxHeight) continue;
count += 1;
if (highest == -1 || H[i] > H[highest]) {
highest = i;
}
}
if (count <= 1) {
return count;
}
else{
return max(1, f(l, highest, D, H[highest] - D) + f(highest + 1, r, D, H[highest] - D));
}
}
int max_towers(int L, int R, int D) {
return f(L, R + 1, D, 2000000000 + 5);
}
# | 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... |