Submission #464445

#TimeUsernameProblemLanguageResultExecution timeMemory
464445pavementTwo Antennas (JOI19_antennas)C++17
13 / 100
3068 ms16756 KiB
#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];
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 (int j = 1; j < i; j++)
			if (j + A[j] <= i && i <= j + B[j] && i - B[i] <= j && j <= i - A[i]) 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;
		}
	}
	for (int i = 1; i <= Q; i++) cout << out[i] << '\n';
}

Compilation message (stderr)

antennas.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   31 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...