제출 #375835

#제출 시각아이디문제언어결과실행 시간메모리
375835casperwangTwo Antennas (JOI19_antennas)C++14
2 / 100
3076 ms2412 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 200000; int N, Q; int h[MAXN+1]; int a[MAXN+1]; int b[MAXN+1]; int l, r; signed main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> N; for (int i = 1; i <= N; i++) { cin >> h[i] >> a[i] >> b[i]; } cin >> Q; for (int i = 0; i < Q; i++) { cin >> l >> r; int ans = -1; for (int j = l; j <= r; j++) { for (int k = l; k <= r; k++) { if (j == k) continue; int dis = abs(j-k); if (dis >= a[j] && dis <= b[j] && dis >= a[k] && dis <= b[k]) { ans = max(ans, abs(h[j] - h[k])); } } } cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...