#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> A, B, H;
int k;
int n;
void init(int N, vector<int> h) {
n = N;
k = n - 1;
H = h;
for (int i = 0; i < n - 1; i++) {
if (h[i] < h[i + 1]) {
A.push_back(h[i]);
} else {
k = i;
break;
}
}
for (int i = n - 1; i > 0; i--) {
if (h[i] < h[i - 1]) {
B.push_back(h[i]);
}
}
}
int max_towers(int L, int R, int D) {
int l = upper_bound(A.begin(), A.end(), H[k] - D) - A.begin();
int r = upper_bound(B.begin(), B.end(), H[k] - D) - B.begin();
r = n - r;
int a = max(0, l - L);
int b = max(0, R - r);
if (a > 0 && b > 0) {
return a + b;
} else {
return 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
293 ms |
1360 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 |
1 ms |
208 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 |
1 ms |
208 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 |
496 ms |
1848 KB |
1st lines differ - on the 1st token, expected: '11903', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
303 ms |
592 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 |
1 ms |
208 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 |
293 ms |
1360 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |