Submission #640026

#TimeUsernameProblemLanguageResultExecution timeMemory
640026maks007Addk (eJOI21_addk)C++14
0 / 100
124 ms1204 KiB
#include "bits/stdc++.h" #define int long long signed main () { int n, k; scanf("%lld%lld", &n, &k); int a[n]; for(int i = 0; i < n; i ++) scanf("%lld", &a[i]); int pref[n]; pref[0] = a[0]; for(int i = 1; i < n; i ++) pref[i] = pref[i - 1] + a[i]; int q; scanf("%lld", &q); while(q --) { int type; scanf("%lld", &type); if(type == 1) { int asdf, gh, jkl; scanf("%lld%lld%lld", &asdf, &gh, &jkl); continue; } int l, r, m; scanf("%lld%lld%lld", &l, &r, &m); l --, r--; int ans = 0; for(int i = l; i <= r - m + 1; i ++) { ans += pref[i + m - 1] - (i - 1 < 0 ? 0 : pref[i-1]); } printf("%lld\n", ans); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%lld%lld", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:9:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  for(int i = 0; i < n; i ++) scanf("%lld", &a[i]);
      |                              ~~~~~^~~~~~~~~~~~~~~
Main.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%lld", &q);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%lld", &type);
      |   ~~~~~^~~~~~~~~~~~~~~
Main.cpp:20:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |    scanf("%lld%lld%lld", &asdf, &gh, &jkl);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%lld%lld%lld", &l, &r, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...