# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1172890 | 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 = a[x] + x; y <= std::min((int64_t)r, b[x] + x); y++) {
if(x <= y - a[y] && x >= y - 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... |