Submission #122803

#TimeUsernameProblemLanguageResultExecution timeMemory
122803PlurmTwo Antennas (JOI19_antennas)C++11
13 / 100
150 ms36732 KiB
#include <bits/stdc++.h>
using namespace std;
int h[2048];
int a[2048];
int b[2048];
int raw[2048][2048];
int qm[2048][2048];
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d%d%d",h+i,a+i,b+i);
    }
    memset(raw, -1, sizeof(raw));
    memset(qm, -1, sizeof(qm));
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            if(max(a[i],a[j]) <= j-i && j-i <= min(b[i],b[j])){
                raw[i][j] = abs(h[i] - h[j]);
            }
        }
    }
    for(int i = n; i > 0; i--){
        for(int j = 1; j <= n; j++){
            qm[i][j] = max(max(qm[i+1][j], qm[i][j-1]), raw[i][j]);
        }
    }
    int q;
    scanf("%d",&q);
    for(int i = 1; i <= q; i++){
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",qm[l][r]);
    }
}
/*
5
10 2 4
1 1 1
2 1 3
1 1 1
100 1 1
5
1 2
2 3
1 3
1 4
1 5
 */

Compilation message (stderr)

antennas.cpp: In function 'int main()':
antennas.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
antennas.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",h+i,a+i,b+i);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
antennas.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&q);
     ~~~~~^~~~~~~~~
antennas.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         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...