Submission #832184

#TimeUsernameProblemLanguageResultExecution timeMemory
832184vjudge1Addk (eJOI21_addk)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
const int nmax = 1e5+5;
int main() {
    int n,k,q;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        p[i] = a[i] + p[i - 1];
    }
    cin >> q;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            cin >> idx[1];
        } else
        if (t == 2) {
        int l, r, m;
        cin >> l >> r >> m;
        long long ans = 0;
        for (int i = l; i <= r; i++) {
            f (i - l + 1 >= m) {
            ans += p[i] - p[i - m];
            }
        }
        cout << ans << endl;
        }
  }
  return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:8:16: error: 'a' was not declared in this scope
    8 |         cin >> a[i];
      |                ^
Main.cpp:9:9: error: 'p' was not declared in this scope
    9 |         p[i] = a[i] + p[i - 1];
      |         ^
Main.cpp:16:20: error: 'idx' was not declared in this scope; did you mean 'index'?
   16 |             cin >> idx[1];
      |                    ^~~
      |                    index
Main.cpp:23:13: error: 'f' was not declared in this scope
   23 |             f (i - l + 1 >= m) {
      |             ^