Submission #1045113

#TimeUsernameProblemLanguageResultExecution timeMemory
1045113NickpapadakAddk (eJOI21_addk)C++14
0 / 100
104 ms1104 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]; // } int re = l+m-1; while(re <=r){ ans += (ps[re]-ps[l-1]); l++;re++; } 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 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: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);
      |         ~~~~~^~~~~~~~~~
Main.cpp:52:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |             scanf("%d", &x);
      |             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...