Submission #111782

#TimeUsernameProblemLanguageResultExecution timeMemory
111782TexTangTwo Antennas (JOI19_antennas)C++14
2 / 100
3039 ms2708 KiB
#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)

antennas.cpp: In function 'int main()':
antennas.cpp:35:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j = 0;j < sub[i].size();j++){
                           ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...