Submission #1045107

#TimeUsernameProblemLanguageResultExecution timeMemory
1045107NickpapadakAddk (eJOI21_addk)C++14
0 / 100
105 ms840 KiB
#include<bits/stdc++.h>
using namespace std;
const unsigned int MAXN = 1e+5 + 10;
int N, K, Q;
int A[MAXN], ps[MAXN];
int solveBF(){
    int ans = 0;
    int l,r,m;
    scanf("%d%d%d",&l,&r,&m);
    // for(int i = l; i <= l+m-1;++i){
    //     ans += ps[l+m-1] - ps[i-1];
    //     // printf("%d %d: %d\n",i,i+m,ans);
    // }
    // ans += (ps[r-m] - ps[l+m-1])*m;
    // for(int i = r-m+1; i <= r; ++i){11
    //     ans += ps[i] - ps[r-m];
    // }
    for(int i = l; i+m-1 <= r; ++i){
        ans += ps[i+m-1]-ps[i-1];
    }
    return max(ans, 0);
}

int scanBF(){
    int k;
        // scanf("%d",&k);
    return -1;
}
 
int BF(int typE){
    if(typE == 1) return scanBF();
    return solveBF();
}
 
int main(){
    scanf("%d%d",&N,&K);
    ps[0] = 0;
    for(int i =1;i<=N;++i){
        scanf("%d", &A[i]);
        ps[i] = ps[i-1] + A[i];
    }
    scanf("%d", &Q);
    while(Q--){
        int b;
        scanf("%d", &b);
        if(b == 2){
            printf("%d\n", solveBF());
        }else{
            int x;
            scanf("%d", &x);
        }
    }
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int scanBF()':
Main.cpp:25:9: warning: unused variable 'k' [-Wunused-variable]
   25 |     int k;
      |         ^
Main.cpp: In function 'int solveBF()':
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%d%d",&l,&r,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d%d",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         scanf("%d", &A[i]);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     scanf("%d", &Q);
      |     ~~~~~^~~~~~~~~~
Main.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         scanf("%d", &b);
      |         ~~~~~^~~~~~~~~~
Main.cpp:50:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |             scanf("%d", &x);
      |             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...