#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 1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
382 ms |
1320 KB |
12th lines differ - on the 1st token, expected: '2', found: '35364' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
666 ms |
1840 KB |
1st lines differ - on the 1st token, expected: '11903', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
335 ms |
592 KB |
1st lines differ - on the 1st token, expected: '7197', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
382 ms |
1320 KB |
12th lines differ - on the 1st token, expected: '2', found: '35364' |
2 |
Halted |
0 ms |
0 KB |
- |