This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#ifdef local
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(a...) qqbx(#a, a)
template <typename ...T> void qqbx(const char *s, T ...a) {
int cnt = sizeof...(T);
((std::cerr << "(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\n")));
}
#else
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
using namespace std;
const int maxn = 200025;
int H[maxn], A[maxn], B[maxn];
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> H[i] >> A[i] >> B[i];
int q;
cin >> q;
while (q--) {
int l, r;
cin >> l >> r;
int ans = -1;
for (int i = l; i <= r; i++) {
for (int j = l; j < i; j++) {
if (max(A[i], A[j]) <= (i-j) && (i-j) <= min(B[i], B[j]))
ans = max(ans, abs(H[i] - H[j]));
}
}
cout << ans << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |