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 <iostream>
#include<vector>
#include<cmath>
using namespace std;
struct antenna {
int l; int r; long long h;
};
int main()
{
int n;
cin >> n;
vector<antenna> ant(n);
for (int i = 0; i < n; i++) {
cin >> ant[i].h >> ant[i].l >> ant[i].r;
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int x, y; cin >> x >> y; int max = -1;
for (int a = x; a <= y-1; a++) {
for (int b = x + 1; b <= y; b++) {
bool rangealeft = false; bool rangearight = false; bool rangebleft = false; bool rangebright = false;
if (a - ant[a - 1].l >= b && a - ant[a - 1].r <= b) {
rangealeft = true;
}
if (b - ant[b - 1].l >= a && b - ant[b - 1].r <= a) {
rangebleft = true;
}
if (a + ant[a - 1].l <= b && a + ant[a - 1].r >= b) {
rangearight = true;
}
if (b + ant[b - 1].l <= a && b + ant[b - 1].r >= a) {
rangebright = true;
}
if ((rangealeft||rangearight)&&(rangebleft||rangebright)) {
if (abs(ant[a - 1].h - ant[b - 1].h) > max) {
max = abs(ant[a - 1].h - ant[b - 1].h);
}
}
}
}
cout << max << 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... |