Submission #375787

#TimeUsernameProblemLanguageResultExecution timeMemory
3757872qbingxuanTwo Antennas (JOI19_antennas)C++14
2 / 100
3091 ms2412 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...