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>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;
struct tower{
ll h;
ll a,b;
};
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
vector <tower> arr(n+1);
for (int z=0;z<n;z++){
tower temp;
cin >> temp.h >> temp.a >> temp.b;
arr[z+1] = temp;
}
ll q;
cin >> q;
for (int z=0;z<q;z++){
ll a,b;
cin >> a >> b;
ll ans = -1;
for (int x=a;x<=b;x++){
for (int y=x+1;y<=b;y++){
if ( y <= x + arr[x].b && y >= x + arr[x].a &&
x >= y - arr[y].b && x <= y - arr[y].a)
ans = max(ans,abs(arr[x].h-arr[y].h));
}
}
cout << ans << endl;
}
cin >> q;
}
# | 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... |