-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-1-4.cpp
More file actions
26 lines (25 loc) · 687 Bytes
/
3-1-4.cpp
File metadata and controls
26 lines (25 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, m; cin >> n >> m;
vector<int>A(n);
for (auto& a : A)
cin >> a;
for (int i = 0; i < m; i++) {
int op; cin >> op;
if (op == 1) {
int x, y, z; cin >> x >> y >> z;
assert(0 <= x && x <= y && y < n);
for (int j = x; j <= y; j++)
A[j] += z;
}
else {
long long answer = 0;
int x, y; cin >> x >> y;
assert(0 <= x && x <= y && y < n);
for (int j = x; j <= y; j++)
answer += A[j];
cout << answer << '\n';
}
}
}