This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define ll long long
#define ull unsigned ll
#define pii pair<int, int>
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
vector<ll> h(n); //heights
vector<pii> a(n); //Bereiche
for(int i = 0; i < n; i++)
{
cin>>h[i]>>a[i].first>>a[i].second;
}
int q;
cin>>q;
for(int i = 0; i < q; i++)
{
int l, r;
cin>>l>>r;
l--; r--;
ll output = -1;
for(int j = l; j < r; j++)
{
for(int k = j+1; k <= r; k++)
{
if(a[j].first+j <= k && k <= a[j].second+j && k-a[k].first >= j && k-a[k].second <= j)
{
output = max(output, abs(h[j] - h[k]));
}
}
}
cout<<output<<"\n";
}
return 0;
}
# | 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... |