#include "towers.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> h;
int ans = 0;
void init(int N, std::vector<int> H) {
n = N;
h = H;
}
void seg(int l, int r, int d){
if(l == r) {
ans++; return;
}
else if(l>r) return;
int mx = -1; int ind = -1;
for(int i = l; i<=r; i++){
if(mx<h[i]){
mx = h[i];
ind = i;
}
}
bool band = true;
for(int i = l; i<=r; i++){
if(i == ind) continue;
if(h[i]>mx-d){
band = false;
}
}
if(band) {
seg(l,ind-1,d);
seg(ind+1,r,d);
}
}
int max_towers(int L, int R, int D) {
ans = 0;
seg(L,R,D);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1382 ms |
1112 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4083 ms |
1368 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2515 ms |
688 KB |
1st lines differ - on the 1st token, expected: '7197', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1382 ms |
1112 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |