# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111782 | TexTang | Two Antennas (JOI19_antennas) | C++14 | 3039 ms | 2708 KiB |
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>
using namespace std;
typedef long long ll;
int main () {
int n;cin >> n;
int height[n + 1]; bool con[n + 1][n + 1];
for(int i = 0;i <= n;i++)
for(int j = 0;j <= n;j++)
con[i][j] = false;
for(int i = 1,u,v;i <= n;i++){
cin >> height[i] >> u >> v;
for(int j = i + u;j <= i + v && j <= n;j++){
con[i][j] = true;
}
for(int j = i - u;j >= 0 && j >= i - v;j--){
con[i][j] = true;
}
}
vector <int> sub[n + 1];
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
if(con[i][j] && con[j][i]){
sub[i].push_back(j);
}
}
}
int q; cin >> q;
for(int p = 0;p < q;p++){
int u,v;
cin >> u >> v;
int ans = -1;
for(int i = u;i <= v;i++){
for(int j = 0;j < sub[i].size();j++){
if(sub[i][j] <= v && sub[i][j] >= u){
ans = max(ans, abs(height[i] - height[sub[i][j]]));
}
}
}
cout << ans << endl;;
}
}
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... |