Submission #1284952

#TimeUsernameProblemLanguageResultExecution timeMemory
1284952tuncay_pashaAddk (eJOI21_addk)C++20
36 / 100
2095 ms4560 KiB
// Try to be as positive as natural numbers :)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#include "bits/stdc++.h"

#define int long long

const int N = 1e5 + 5;

int a[N], pre[N];

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, k;
  std::cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    std::cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    pre[i] = pre[i - 1] + a[i];
  }
  int q;
  std::cin >> q;
  while (q--) {
    int t;
    std::cin >> t;
    if (t == 1) {
      int i;
      std::cin >> i;
      continue;
    }
    int l, r, m;
    std::cin >> l >> r >> m;
    int sum = pre[l + m - 1] - pre[l - 1], ans = sum;
    for (int i = l + m; i <= r; ++i) {
      sum += a[i] - a[i - m];
      ans += sum;
    }
    std::cout << ans << '\n';
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...