Submission #122730

#TimeUsernameProblemLanguageResultExecution timeMemory
122730win11905Two Antennas (JOI19_antennas)C++11
13 / 100
113 ms19704 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2005; int n, m; int h[N], x[N], y[N]; int cost[N][N]; int main() { memset(cost, -1, sizeof cost); scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d %d %d", h+i, x+i, y+i); for(int i = 1; i <= n; ++i) { for(int j = i+x[i]; j <= min(n, i+y[i]); ++j) { if(x[j] <= j-i && j-i <= y[j]) cost[i][j] = max(cost[i][j], abs(h[i] - h[j])); } } for(int sz = 2; sz <= n; ++sz) { for(int l = 1, r = sz; r <= n; ++l, ++r) { cost[l][r] = max({cost[l][r], cost[l+1][r], cost[l][r-1]}); } } scanf("%d", &m); while(m--) { int l, r; scanf("%d %d", &l, &r); printf("%d\n", cost[l][r]); } }

Compilation message (stderr)

antennas.cpp: In function 'int main()':
antennas.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
antennas.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", h+i, x+i, y+i);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
antennas.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
antennas.cpp:27:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int l, r; scanf("%d %d", &l, &r);
                   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...