Submission #111779

#TimeUsernameProblemLanguageResultExecution timeMemory
111779TexTangTwo Antennas (JOI19_antennas)C++14
2 / 100
3093 ms1572 KiB
#include <iostream> 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; } } 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 = u;j <= v;j++){ if(con[i][j] && con[j][i]){ // cout << i << " " << j << " " << height[i] << " " << height[j] << " " << height[i] - height[j] << endl; ans = max(ans, abs(height[i] - height[j])); } } } cout << ans << 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...