Submission #1289993

#TimeUsernameProblemLanguageResultExecution timeMemory
1289993austinAddk (eJOI21_addk)C++20
36 / 100
2094 ms2912 KiB
#include <bits/stdc++.h>
using namespace std;
int main() {
  int16_t type;
  long long temp, counter = 0, window;
  int n, k, q, l, r, m, i, j, s;
  scanf("%d %d", &n, &k);
  vector<long long> v(n+1);
  vector<int> operations(k);
  for (i=1; i<=n; i++) {
    scanf("%lld", &v[i]);
  }
  scanf("%d", &q);
  for (i=0; i<q; i++) {
    scanf("%hd", &type);
    if (type == 1) {
      for (j=0; j<k; j++) {
        scanf("%d", &operations[j]);
      }
      temp = v[operations[0]];
      for (j=1; j<k; j++) {
        v[operations[j-1]] = v[operations[j]];
      }
      v[operations[k-1]] = temp;
    } else {
      scanf("%d %d %d", &l, &r, &m);
      window = 0;
      counter = 0;
      for (j=l; j<l+m; j++) {
        window += v[j];
      }
      counter += window;
      for (j=l+m; j<=r; j++) {
        window += v[j] - v[j-m];
        counter += window;
      }
      printf("%lld\n", counter);
    }
  }
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:7:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |   scanf("%d %d", &n, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld", &v[i]);
      |     ~~~~~^~~~~~~~~~~~~~~
Main.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &q);
      |   ~~~~~^~~~~~~~~~
Main.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%hd", &type);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d", &operations[j]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:26:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |       scanf("%d %d %d", &l, &r, &m);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...