Submission #464449

# Submission time Handle Problem Language Result Execution time Memory
464449 2021-08-13T08:50:04 Z pavement Two Antennas (JOI19_antennas) C++17
13 / 100
3000 ms 24280 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int N, Q, H[200005], A[200005], B[200005], T[200005], out[200005];
bool act[200005];
vector<int> toact[200005], todeact[200005];
vector<ii> qu[200005];

main() {
	memset(T, -1, sizeof T);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> H[i] >> A[i] >> B[i];
	cin >> Q;
	for (int i = 1, L, R; i <= Q; i++) {
		cin >> L >> R;
		qu[R].eb(L, i);
	}
	for (int i = 1; i <= N; i++) {
		for (auto j : toact[i]) act[j] = 1;
		for (auto j : todeact[i]) act[j] = 0;
		for (int j = max(1ll, i - B[i]); j <= i - A[i]; j++)
			if (act[j]) T[j] = max(T[j], llabs(H[i] - H[j]));
		for (auto u : qu[i]) {
			int ans = -1;
			for (int k = u.first; k <= i; k++) ans = max(ans, T[k]);
			out[u.second] = ans;
		}
		if (i + A[i] <= N) toact[i + A[i]].pb(i);
		if (i + B[i] + 1 <= N) todeact[i + B[i] + 1].pb(i);
	}
	for (int i = 1; i <= Q; i++) cout << out[i] << '\n';
}

Compilation message

antennas.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 15948 KB Output is correct
2 Correct 9 ms 15948 KB Output is correct
3 Correct 9 ms 15948 KB Output is correct
4 Correct 10 ms 16088 KB Output is correct
5 Correct 10 ms 15948 KB Output is correct
6 Correct 9 ms 15960 KB Output is correct
7 Correct 11 ms 15920 KB Output is correct
8 Correct 9 ms 15948 KB Output is correct
9 Correct 11 ms 15948 KB Output is correct
10 Correct 9 ms 16076 KB Output is correct
11 Correct 9 ms 15972 KB Output is correct
12 Correct 9 ms 16036 KB Output is correct
13 Correct 9 ms 16020 KB Output is correct
14 Correct 9 ms 15916 KB Output is correct
15 Correct 9 ms 15948 KB Output is correct
16 Correct 9 ms 16016 KB Output is correct
17 Correct 10 ms 16024 KB Output is correct
18 Correct 9 ms 15948 KB Output is correct
19 Correct 9 ms 15944 KB Output is correct
20 Correct 9 ms 15948 KB Output is correct
21 Correct 9 ms 15904 KB Output is correct
22 Correct 9 ms 15936 KB Output is correct
23 Correct 9 ms 16028 KB Output is correct
24 Correct 9 ms 15948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 15948 KB Output is correct
2 Correct 9 ms 15948 KB Output is correct
3 Correct 9 ms 15948 KB Output is correct
4 Correct 10 ms 16088 KB Output is correct
5 Correct 10 ms 15948 KB Output is correct
6 Correct 9 ms 15960 KB Output is correct
7 Correct 11 ms 15920 KB Output is correct
8 Correct 9 ms 15948 KB Output is correct
9 Correct 11 ms 15948 KB Output is correct
10 Correct 9 ms 16076 KB Output is correct
11 Correct 9 ms 15972 KB Output is correct
12 Correct 9 ms 16036 KB Output is correct
13 Correct 9 ms 16020 KB Output is correct
14 Correct 9 ms 15916 KB Output is correct
15 Correct 9 ms 15948 KB Output is correct
16 Correct 9 ms 16016 KB Output is correct
17 Correct 10 ms 16024 KB Output is correct
18 Correct 9 ms 15948 KB Output is correct
19 Correct 9 ms 15944 KB Output is correct
20 Correct 9 ms 15948 KB Output is correct
21 Correct 9 ms 15904 KB Output is correct
22 Correct 9 ms 15936 KB Output is correct
23 Correct 9 ms 16028 KB Output is correct
24 Correct 9 ms 15948 KB Output is correct
25 Correct 94 ms 21912 KB Output is correct
26 Correct 25 ms 16620 KB Output is correct
27 Correct 169 ms 24108 KB Output is correct
28 Correct 190 ms 24132 KB Output is correct
29 Correct 94 ms 21856 KB Output is correct
30 Correct 130 ms 21500 KB Output is correct
31 Correct 91 ms 23312 KB Output is correct
32 Correct 188 ms 24152 KB Output is correct
33 Correct 137 ms 23688 KB Output is correct
34 Correct 96 ms 19832 KB Output is correct
35 Correct 161 ms 24004 KB Output is correct
36 Correct 192 ms 24280 KB Output is correct
37 Correct 108 ms 20164 KB Output is correct
38 Correct 182 ms 23168 KB Output is correct
39 Correct 37 ms 16968 KB Output is correct
40 Correct 196 ms 23272 KB Output is correct
41 Correct 135 ms 21236 KB Output is correct
42 Correct 187 ms 23340 KB Output is correct
43 Correct 66 ms 18388 KB Output is correct
44 Correct 181 ms 23196 KB Output is correct
45 Correct 39 ms 17220 KB Output is correct
46 Correct 184 ms 23272 KB Output is correct
47 Correct 54 ms 17812 KB Output is correct
48 Correct 184 ms 23236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3067 ms 23176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 15948 KB Output is correct
2 Correct 9 ms 15948 KB Output is correct
3 Correct 9 ms 15948 KB Output is correct
4 Correct 10 ms 16088 KB Output is correct
5 Correct 10 ms 15948 KB Output is correct
6 Correct 9 ms 15960 KB Output is correct
7 Correct 11 ms 15920 KB Output is correct
8 Correct 9 ms 15948 KB Output is correct
9 Correct 11 ms 15948 KB Output is correct
10 Correct 9 ms 16076 KB Output is correct
11 Correct 9 ms 15972 KB Output is correct
12 Correct 9 ms 16036 KB Output is correct
13 Correct 9 ms 16020 KB Output is correct
14 Correct 9 ms 15916 KB Output is correct
15 Correct 9 ms 15948 KB Output is correct
16 Correct 9 ms 16016 KB Output is correct
17 Correct 10 ms 16024 KB Output is correct
18 Correct 9 ms 15948 KB Output is correct
19 Correct 9 ms 15944 KB Output is correct
20 Correct 9 ms 15948 KB Output is correct
21 Correct 9 ms 15904 KB Output is correct
22 Correct 9 ms 15936 KB Output is correct
23 Correct 9 ms 16028 KB Output is correct
24 Correct 9 ms 15948 KB Output is correct
25 Correct 94 ms 21912 KB Output is correct
26 Correct 25 ms 16620 KB Output is correct
27 Correct 169 ms 24108 KB Output is correct
28 Correct 190 ms 24132 KB Output is correct
29 Correct 94 ms 21856 KB Output is correct
30 Correct 130 ms 21500 KB Output is correct
31 Correct 91 ms 23312 KB Output is correct
32 Correct 188 ms 24152 KB Output is correct
33 Correct 137 ms 23688 KB Output is correct
34 Correct 96 ms 19832 KB Output is correct
35 Correct 161 ms 24004 KB Output is correct
36 Correct 192 ms 24280 KB Output is correct
37 Correct 108 ms 20164 KB Output is correct
38 Correct 182 ms 23168 KB Output is correct
39 Correct 37 ms 16968 KB Output is correct
40 Correct 196 ms 23272 KB Output is correct
41 Correct 135 ms 21236 KB Output is correct
42 Correct 187 ms 23340 KB Output is correct
43 Correct 66 ms 18388 KB Output is correct
44 Correct 181 ms 23196 KB Output is correct
45 Correct 39 ms 17220 KB Output is correct
46 Correct 184 ms 23272 KB Output is correct
47 Correct 54 ms 17812 KB Output is correct
48 Correct 184 ms 23236 KB Output is correct
49 Execution timed out 3067 ms 23176 KB Time limit exceeded
50 Halted 0 ms 0 KB -