#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
int N, p;
vector<int> H;
void init(int n, vector<int> h) {
N = n, H = h;
for (int i = 0; i < N; i++) {
if ((i == 0 || H[i] > H[i - 1]) && (i == N - 1 || H[i] > H[i + 1])) {
p = i;
}
}
}
int max_towers(int L, int R, int D) {
int l = upper_bound(H.begin(), H.end(), H[p] - D) - H.begin() - 1;
int r = lower_bound(H.begin(), H.end(), H[p] - D, [&](int x, int y) {return x >= y;}) - H.begin() - 1;
return max(0, l - L + 1) + max(0, R - r + 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
347 ms |
976 KB |
1st lines differ - on the 1st token, expected: '1', found: '57511' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '19' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '19' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
458 ms |
1360 KB |
1st lines differ - on the 1st token, expected: '11903', found: '121571' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
245 ms |
556 KB |
1st lines differ - on the 1st token, expected: '7197', found: '36474' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '19' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
347 ms |
976 KB |
1st lines differ - on the 1st token, expected: '1', found: '57511' |
2 |
Halted |
0 ms |
0 KB |
- |