Submission #1176259

#TimeUsernameProblemLanguageResultExecution timeMemory
1176259avighnaTwo Antennas (JOI19_antennas)C++20
2 / 100
3096 ms2372 KiB
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::vector<int> h(n), a(n), b(n); for (int i = 0; i < n; ++i) { std::cin >> h[i] >> a[i] >> b[i]; } auto comm = [&](int i, int j) { return (i + a[i] <= j and j <= i + b[i]) or (i - b[i] <= j and j <= i - a[i]); }; int q; std::cin >> q; while (q--) { int l, r; std::cin >> l >> r; --l, --r; int ans = -1; for (int i = l; i <= r; ++i) { for (int j = i + 1; j <= r; ++j) { if (comm(i, j) and comm(j, i)) { ans = std::max(ans, std::abs(h[i] - h[j])); } } } std::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...