#include "towers.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define nL '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
void eval(bool condition) { cout << (condition ? "yes" : "no") << nL; }
void Eval(bool condition) { cout << (condition ? "Yes" : "No") << nL; }
int ipow(int a, int n) {
if (n == 0) return 1;
int x = ipow(a, n/2);
if (n % 2 == 0) return x*x;
return x*x*a;
}
template <typename T>
ostream& operator<<(ostream& stream, const vector<T>& v) {
for (auto elem : v)
stream << elem << " ";
return stream;
}
template <typename T>
istream& operator>>(istream& stream, vector<T>& v){
for(auto &elem : v)
stream >> elem;
return stream;
}
int n;
vi heights;
void init(int N, std::vector<int> H) {
n = N;
heights = H;
}
int max_towers(int L, int R, int D) {
vi dp(n, 1);
int res = 0;
for (int i = L; i <= R; i++) {
int tower = heights[i-1];
for (int j = i-2; j >= L; j--) {
if (tower-D >= heights[i] && tower-D >= heights[j]) dp[i] = max(dp[i], dp[j]+1);
tower = max(tower, heights[j]);
}
res = max(dp[i], res);
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4046 ms |
996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 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 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
8 ms |
208 KB |
Output is correct |
21 |
Correct |
8 ms |
312 KB |
Output is correct |
22 |
Correct |
7 ms |
208 KB |
Output is correct |
23 |
Correct |
3 ms |
212 KB |
Output is correct |
24 |
Correct |
4 ms |
320 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
4 ms |
208 KB |
Output is correct |
27 |
Correct |
4 ms |
208 KB |
Output is correct |
28 |
Correct |
5 ms |
312 KB |
Output is correct |
29 |
Correct |
4 ms |
208 KB |
Output is correct |
30 |
Correct |
5 ms |
312 KB |
Output is correct |
31 |
Correct |
4 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
208 KB |
Output is correct |
35 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 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 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
8 ms |
208 KB |
Output is correct |
21 |
Correct |
8 ms |
312 KB |
Output is correct |
22 |
Correct |
7 ms |
208 KB |
Output is correct |
23 |
Correct |
3 ms |
212 KB |
Output is correct |
24 |
Correct |
4 ms |
320 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
4 ms |
208 KB |
Output is correct |
27 |
Correct |
4 ms |
208 KB |
Output is correct |
28 |
Correct |
5 ms |
312 KB |
Output is correct |
29 |
Correct |
4 ms |
208 KB |
Output is correct |
30 |
Correct |
5 ms |
312 KB |
Output is correct |
31 |
Correct |
4 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
208 KB |
Output is correct |
35 |
Correct |
4 ms |
208 KB |
Output is correct |
36 |
Correct |
552 ms |
1056 KB |
Output is correct |
37 |
Correct |
1120 ms |
1456 KB |
Output is correct |
38 |
Correct |
256 ms |
1464 KB |
Output is correct |
39 |
Correct |
672 ms |
1464 KB |
Output is correct |
40 |
Correct |
259 ms |
1464 KB |
Output is correct |
41 |
Execution timed out |
4075 ms |
1432 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4056 ms |
1456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4033 ms |
552 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 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 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
8 ms |
208 KB |
Output is correct |
21 |
Correct |
8 ms |
312 KB |
Output is correct |
22 |
Correct |
7 ms |
208 KB |
Output is correct |
23 |
Correct |
3 ms |
212 KB |
Output is correct |
24 |
Correct |
4 ms |
320 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
4 ms |
208 KB |
Output is correct |
27 |
Correct |
4 ms |
208 KB |
Output is correct |
28 |
Correct |
5 ms |
312 KB |
Output is correct |
29 |
Correct |
4 ms |
208 KB |
Output is correct |
30 |
Correct |
5 ms |
312 KB |
Output is correct |
31 |
Correct |
4 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
208 KB |
Output is correct |
35 |
Correct |
4 ms |
208 KB |
Output is correct |
36 |
Correct |
552 ms |
1056 KB |
Output is correct |
37 |
Correct |
1120 ms |
1456 KB |
Output is correct |
38 |
Correct |
256 ms |
1464 KB |
Output is correct |
39 |
Correct |
672 ms |
1464 KB |
Output is correct |
40 |
Correct |
259 ms |
1464 KB |
Output is correct |
41 |
Execution timed out |
4075 ms |
1432 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4046 ms |
996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |