Submission #829471

#TimeUsernameProblemLanguageResultExecution timeMemory
829471MohamedAhmed04Two Antennas (JOI19_antennas)C++14
2 / 100
3069 ms5236 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...