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 ;
const int MAX = 1e5 + 10 ;
int arr[MAX] , L[MAX] , R[MAX] ;
int n , q ;
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
cin>>n ;
for(int i = 1 ; i <= n ; ++i)
cin>>arr[i]>>L[i]>>R[i] ;
cin>>q ;
while(q--)
{
int l , r ;
cin>>l>>r ;
int ans = -1 ;
for(int i = l ; i <= r ; ++i)
{
for(int j = i+L[i] ; j <= min(r , i+R[i]) ; ++j)
{
if(j-i >= L[j] && j-i <= R[j])
ans = max(ans , abs(arr[i] - arr[j])) ;
}
}
cout<<ans<<"\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... |