Submission #742613

#TimeUsernameProblemLanguageResultExecution timeMemory
742613nguyentunglamTwo Antennas (JOI19_antennas)C++17
2 / 100
3069 ms6476 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 2e5 + 10; int h[N], a[N], b[N]; int main() { #define task "" cin.tie(0) -> sync_with_stdio(0); // if (fopen ("task.inp", "r")) { // freopen ("task.inp", "r", stdin); // freopen ("task.out", "w", stdout); // } // if (fopen (task".inp", "r")) { // freopen (task".inp", "r", stdin); // freopen (task".out", "w", stdout); // } 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 = i + 1; j <= r; j++) { int dist = j - i; if (a[i] <= dist && dist <= b[i] && a[j] <= dist && dist <= b[j]) ans = max(ans, abs(h[i] - h[j])); } cout << ans << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...