// In the name of Allah
#include <bits/stdc++.h>
#include "towers.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define Mp make_pair
#define pb push_back
#define endl '\n'
#define sep ' '
const int maxn = 1e5 + 7;
const ll oo = 1e9 + 7;
int n;
ll A[maxn];
int M[maxn], sm[maxn];
void init(int N, vector<int> H) {
n = N;
for (int i = 0; i < n; i++) A[i] = H[i];
for (int i = 1; i < n - 1; i++) {
if (A[i] < A[i - 1] && A[i] < A[i + 1]) M[i] = 1;
else M[i] = 0;
}
for (int i = 1; i <= n; i++) sm[i] = sm[i - 1] + M[i - 1];
}
int max_towers(int L, int R, int D) {
int res = sm[R + 1] - sm[L];
if (R - L + 1 == 1) {
if (M[L] == 0) res++;
}
else {
if (M[L] == 0 && A[L] < A[L + 1]) res++;
if (M[R] == 0 && A[R] < A[R - 1]) res++;
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
226 ms |
1624 KB |
2nd lines differ - on the 1st token, expected: '1', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
386 ms |
2648 KB |
Output is correct |
2 |
Correct |
521 ms |
2648 KB |
Output is correct |
3 |
Correct |
548 ms |
2648 KB |
Output is correct |
4 |
Correct |
511 ms |
2648 KB |
Output is correct |
5 |
Correct |
515 ms |
2648 KB |
Output is correct |
6 |
Correct |
477 ms |
2648 KB |
Output is correct |
7 |
Correct |
571 ms |
2900 KB |
Output is correct |
8 |
Correct |
507 ms |
2648 KB |
Output is correct |
9 |
Correct |
545 ms |
2648 KB |
Output is correct |
10 |
Correct |
481 ms |
2648 KB |
Output is correct |
11 |
Correct |
507 ms |
2648 KB |
Output is correct |
12 |
Correct |
508 ms |
2636 KB |
Output is correct |
13 |
Correct |
567 ms |
2648 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
10 ms |
2628 KB |
Output is correct |
18 |
Correct |
16 ms |
2648 KB |
Output is correct |
19 |
Correct |
7 ms |
2648 KB |
Output is correct |
20 |
Correct |
7 ms |
2648 KB |
Output is correct |
21 |
Correct |
7 ms |
2740 KB |
Output is correct |
22 |
Correct |
8 ms |
2648 KB |
Output is correct |
23 |
Correct |
13 ms |
2736 KB |
Output is correct |
24 |
Correct |
8 ms |
2648 KB |
Output is correct |
25 |
Correct |
8 ms |
2632 KB |
Output is correct |
26 |
Correct |
12 ms |
2632 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
344 KB |
Output is correct |
35 |
Correct |
1 ms |
344 KB |
Output is correct |
36 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
166 ms |
856 KB |
1st lines differ - on the 1st token, expected: '7197', found: '8004' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
226 ms |
1624 KB |
2nd lines differ - on the 1st token, expected: '1', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |