제출 #111962

#제출 시각아이디문제언어결과실행 시간메모리
111962lauzm0Two Antennas (JOI19_antennas)C++14
2 / 100
3028 ms4984 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...