#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debug_out(){cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
cerr << H << ' ';
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 1e5 + 10;
const int lg = 20;
int n, x, h[maxn], part[maxn];
void init(int N, std::vector<int> H) {
n = N;
for (int i = 0; i < n; i++){
h[i] = H[i];
}
for (int i = 1; i + 1 < n; i++){
if (h[i] < h[i-1] && h[i] < h[i+1]) part[i]++;
}
for (int i = 1; i < n; i++){
part[i] += part[i-1];
}
}
int max_towers(int L, int R, int D) {
if (R-L <= 1) return 1;
return part[R-1] - part[L] + (h[L] < h[L+1]) + (h[R] < h[R-1]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
266 ms |
1196 KB |
2nd lines differ - on the 1st token, expected: '1', 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: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
566 ms |
1840 KB |
Output is correct |
2 |
Correct |
601 ms |
1836 KB |
Output is correct |
3 |
Correct |
604 ms |
1852 KB |
Output is correct |
4 |
Correct |
618 ms |
1872 KB |
Output is correct |
5 |
Correct |
530 ms |
1760 KB |
Output is correct |
6 |
Correct |
741 ms |
1744 KB |
Output is correct |
7 |
Correct |
718 ms |
1864 KB |
Output is correct |
8 |
Correct |
811 ms |
1856 KB |
Output is correct |
9 |
Correct |
692 ms |
1864 KB |
Output is correct |
10 |
Correct |
658 ms |
1840 KB |
Output is correct |
11 |
Correct |
632 ms |
1832 KB |
Output is correct |
12 |
Correct |
717 ms |
1860 KB |
Output is correct |
13 |
Correct |
629 ms |
1744 KB |
Output is correct |
14 |
Correct |
0 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
336 KB |
Output is correct |
17 |
Correct |
16 ms |
1736 KB |
Output is correct |
18 |
Correct |
10 ms |
1836 KB |
Output is correct |
19 |
Correct |
10 ms |
1848 KB |
Output is correct |
20 |
Correct |
10 ms |
1836 KB |
Output is correct |
21 |
Correct |
10 ms |
1832 KB |
Output is correct |
22 |
Correct |
10 ms |
1856 KB |
Output is correct |
23 |
Correct |
10 ms |
1864 KB |
Output is correct |
24 |
Correct |
10 ms |
1836 KB |
Output is correct |
25 |
Correct |
9 ms |
1840 KB |
Output is correct |
26 |
Correct |
10 ms |
1832 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
0 ms |
208 KB |
Output is correct |
30 |
Correct |
0 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
0 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
0 ms |
336 KB |
Output is correct |
36 |
Correct |
0 ms |
236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
219 ms |
592 KB |
1st lines differ - on the 1st token, expected: '7197', found: '8004' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
266 ms |
1196 KB |
2nd lines differ - on the 1st token, expected: '1', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |