Submission #1074031

# Submission time Handle Problem Language Result Execution time Memory
1074031 2024-08-25T06:51:38 Z Gromp15 Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 94256 KB
#include <bits/stdc++.h>
#include "towers.h"
#define ll long long
#define ar array
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T> bool ckmin(T &a, const T &b ) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b ) { return a < b ? a = b, 1 : 0; }

int N; vector<int> h;
void init(int _N, std::vector<int> H) {
	N = _N;
	h = H;
}

int max_towers(int L, int R, int D) {
	map<ar<int, 3>, int> mp;
	auto solve = [&](auto&& s, int l, int r, int lim) -> int {
		if (mp.count({l, r, lim})) return mp[{l, r, lim}];
		if (l > r) return 0;
		if (l == r) return h[l] <= lim;
		int p = l;
		for (int i = l+1; i <= r; i++) if (h[i] > h[p]) p = i;
		return mp[{l, r, lim}] = max({s(s, l, p-1, lim), s(s, p+1, r, lim), int(h[p] <= lim), s(s, l, p-1, h[p] - D) + s(s, p+1, r, h[p] - D)});
	};
	solve(solve, L, R, 1e9);
	return solve(solve, L, R, 1e9);
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4037 ms 84584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 856 KB Output is correct
3 Correct 4 ms 856 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 19 ms 2108 KB Output is correct
9 Correct 103 ms 6736 KB Output is correct
10 Correct 11 ms 1368 KB Output is correct
11 Correct 77 ms 5196 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 609 ms 23284 KB Output is correct
14 Correct 305 ms 14444 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 4 ms 856 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 59 ms 4360 KB Output is correct
19 Correct 190 ms 10256 KB Output is correct
20 Correct 10 ms 1368 KB Output is correct
21 Correct 6 ms 1112 KB Output is correct
22 Correct 7 ms 1112 KB Output is correct
23 Execution timed out 4064 ms 94256 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 856 KB Output is correct
3 Correct 4 ms 856 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 19 ms 2108 KB Output is correct
9 Correct 103 ms 6736 KB Output is correct
10 Correct 11 ms 1368 KB Output is correct
11 Correct 77 ms 5196 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 609 ms 23284 KB Output is correct
14 Correct 305 ms 14444 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 4 ms 856 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 59 ms 4360 KB Output is correct
19 Correct 190 ms 10256 KB Output is correct
20 Correct 10 ms 1368 KB Output is correct
21 Correct 6 ms 1112 KB Output is correct
22 Correct 7 ms 1112 KB Output is correct
23 Execution timed out 4064 ms 94256 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4054 ms 64472 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 19240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 856 KB Output is correct
3 Correct 4 ms 856 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 19 ms 2108 KB Output is correct
9 Correct 103 ms 6736 KB Output is correct
10 Correct 11 ms 1368 KB Output is correct
11 Correct 77 ms 5196 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 609 ms 23284 KB Output is correct
14 Correct 305 ms 14444 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 4 ms 856 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 59 ms 4360 KB Output is correct
19 Correct 190 ms 10256 KB Output is correct
20 Correct 10 ms 1368 KB Output is correct
21 Correct 6 ms 1112 KB Output is correct
22 Correct 7 ms 1112 KB Output is correct
23 Execution timed out 4064 ms 94256 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4037 ms 84584 KB Time limit exceeded
2 Halted 0 ms 0 KB -