#include <iostream>
#include <vector>
#define ll long long
using namespace std;
int main() {
ll n, k, q, l, r, m;
cin >> n >> k;
vector<ll> a(n), b(n), c(n), u(k);
for(ll i = 0; i < n; i++) {
cin >> a[i];
b[i] = a[i];
c[i] = (i+1)*a[i];
if(i != 0) b[i]+=b[i-1], c[i]+=c[i-1];
}
cin >> q;
while(q--) {
cin >> m;
if(m == 1) {
for(ll i = 0; i < k; i++) cin >> u[i];
} else {
cin >> l >> r >> m;
l--, r--;
if(2*m <= r-l+1) cout << c[l+m-1]-(l-1 < 0 ? 0 : c[l-1])-l*(b[l+m-1]-(l-1 < 0 ? 0 : b[l-1])) << " " << (b[r-m]-b[l+m-1])*m << " " << (r+2)*(b[r]-(r-m < 0 ? 0 : b[r-m]))-(c[r]-c[r-m]) << "\n";
else cout << c[r-m]-(l-1 < 0 ? 0 : c[l-1])-l*(b[r-m]-(l-1 < 0 ? 0 : b[l-1])) << " " << (b[l+m-1]-b[r-m])*(r-l+2-m) << " " << (r+2)*(b[r]-(l+m-1 < 0 ? 0 : b[l+m-1]))-(c[r]-c[l+m-1]) << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
2044 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
3440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |