Submission #111766

#TimeUsernameProblemLanguageResultExecution timeMemory
111766TexTangTwo Antennas (JOI19_antennas)C++14
0 / 100
3 ms512 KiB
#include <iostream> using namespace std; 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 - u - v;j--){ con[i][j] = true; } } /* for(int i = 0;i <= n;i++){ for(int j = 0;j <= n;j++){ cout << con[i][j] << " "; } cout << endl; }*/ 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 << 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...