#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
const int N = 100002;
ll n, K;
int a[N], q;
short int op;
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n >> K;
for (int i = 1; i <= n; ++i)
cin >> a[i];
vector<ll> pref(n+1), pref2(n+1);
for (int i = 1; i <= n; ++i)
pref[i] = pref[i - 1] + a[i];
for (int i = 1; i <= n; ++i)
pref2[i] = pref2[i-1] + a[i]*i;
q; cin >> q;
for (int tc = 1; tc <= q; ++tc) {
cin >> op;
if (op == 1) {
int x; cin >> x;
continue;
}
else {
int l, r, m;
cin >> l >> r >> m;
ll x1 = 0, x2 = 0, x3 = 0;
x1 = (pref2[l + m - 2] - pref2[l - 1]) - (pref[l + m - 2] - pref[l - 1]) * (l-1);
x2 = m * (pref[r - m + 1] - pref[l + m - 2]);
x3 = (r + 1) * (pref[r] - pref[r - m + 1]) - (pref2[r] - pref2[r - m + 1]);
cout << x1 + x2 + x3 << '\n';
}
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:25:2: warning: statement has no effect [-Wunused-value]
25 | q; cin >> q;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
2396 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |