#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
int N;
vector<pair<int, int>> H;
int k;
void init(int N, vector<int> H) {
::N = N;
::H.resize(N);
for (int i = 0; i < N; i++) {
::H[i].first = H[i];
::H[i].second = i;
}
if (N == 2) {
if (H[0] > H[1]) k = 0;
else k = 1;
}
for (int i = 1; i < N - 1; i++) {
if (H[i - 1] < H[i] && H[i] > H[i - 1]) k = i;
}
}
int max_towers(int L, int R, int D) {
if (k >= L && k <= R) {
int lf = H[L].first;
int rg = H[R].first;
int ma = max(lf, rg);
if (H[k].first - ma >= D) return 2;
return 1;
} else {
return 1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
441 ms |
1232 KB |
Output is correct |
2 |
Correct |
763 ms |
1736 KB |
Output is correct |
3 |
Correct |
702 ms |
1872 KB |
Output is correct |
4 |
Correct |
748 ms |
1836 KB |
Output is correct |
5 |
Correct |
808 ms |
1844 KB |
Output is correct |
6 |
Correct |
713 ms |
1832 KB |
Output is correct |
7 |
Correct |
919 ms |
1852 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
540 ms |
1840 KB |
1st lines differ - on the 1st token, expected: '11903', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
310 ms |
592 KB |
1st lines differ - on the 1st token, expected: '7197', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
441 ms |
1232 KB |
Output is correct |
2 |
Correct |
763 ms |
1736 KB |
Output is correct |
3 |
Correct |
702 ms |
1872 KB |
Output is correct |
4 |
Correct |
748 ms |
1836 KB |
Output is correct |
5 |
Correct |
808 ms |
1844 KB |
Output is correct |
6 |
Correct |
713 ms |
1832 KB |
Output is correct |
7 |
Correct |
919 ms |
1852 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
12 |
Halted |
0 ms |
0 KB |
- |