#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> h;
int f[100009], p[100009];
bool used[100009];
void init(int N, std::vector<int> H) {
h = H;
f[0] = 1000000009;
f[N + 1] = 0;
for (int i = 1; i <= N; i++)
{
f[i] = H[i - 1];
}
p[0] = 0;
for (int i = 1; i <= N; i++)
{
p[i] = p[i - 1];
if (f[i - 1] > f[i] && f[i + 1] > f[i])
{
p[i]++;
used[i] = true;
}
}
}
int max_towers(int L, int R, int D) {
L++;
R++;
int ans = p[R] - p[L - 1];
if (!used[L] && f[L - 1] > f[L])
{
ans++;
}
if (L != R && !used[R] && f[R + 1] > f[R])
{
ans++;
}
return max(ans, 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
339 ms |
1488 KB |
12th lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
639 ms |
2212 KB |
1st lines differ - on the 1st token, expected: '11903', found: '11902' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
291 ms |
796 KB |
1st lines differ - on the 1st token, expected: '7197', found: '8004' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
339 ms |
1488 KB |
12th lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |