Submission #1045080

#TimeUsernameProblemLanguageResultExecution timeMemory
1045080NickpapadakAddk (eJOI21_addk)C++14
0 / 100
563 ms836 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){
    //     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;
    for(int i = 1; i<=K;++i){
        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);
        int ans = BF(b);
        if(b != -1) printf("%d\n", ans);
    }
    return 0;
}

Compilation message (stderr)

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 scanBF()':
Main.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf("%d",&k);
      |         ~~~~~^~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d%d",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         scanf("%d", &A[i]);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     scanf("%d", &Q);
      |     ~~~~~^~~~~~~~~~
Main.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf("%d", &b);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...