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>
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
vector<array<int,3>> arr(n);
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < 3; ++j){
cin>>arr[i][j];
}
}
int q;cin>>q;
while (q--){
int l,r;cin>>l>>r;
int ans = -1;
for (int i = l-1; i <= r-1; i++){
for (int j = l-1; j < i; j++){
if (i-j<=min(arr[i][2],arr[j][2]) && i-j>=max(arr[i][1],arr[j][1])){
ans=max(ans,abs(arr[i][0]-arr[j][0]));
}
}
}
cout<<ans<<endl;
}
}
# | 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... |