# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1172878 | lopkus | Two Antennas (JOI19_antennas) | C++20 | 3095 ms | 4420 KiB |
#include <bits/stdc++.h>+
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int64_t> h(n + 1), a(n + 1), b(n + 1);
for(int i = 1; i <= n; i++) {
std::cin >> h[i] >> a[i] >> b[i];
}
int q;
std::cin >> q;
while(q--) {
int l, r;
std::cin >> l >> r;
int64_t ans = - 1;
for(int x = l; x <= r; x++) {
for(int y = x + 1; y <= r; y++) {
if(y - x >= a[x] && y - x <= b[x] && y - x >= a[y] && y - x <= b[y]) {
ans = std::max(ans, std::abs(h[x] - h[y]));
}
}
}
std::cout << ans << "\n";
}
}
Compilation message (stderr)
# | 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... |