#include <bits/stdc++.h>
//#pragma GCC diagnostic warning "-std=c++11"
using namespace std;
int main(){
long long n, k;
cin >> n >> k;
long long arr[n + 1];
long long prefix[n + 1] = {0};
long long prefix2[n + 1] = {0};
for(int i = 1; i <= n; i++){
cin >> arr[i];
prefix[i] = prefix[i - 1] + arr[i];
prefix2[i] = prefix2[i - 1] + arr[i] * i;
}
int q;
cin >> q;
while(q--){
int oneOrTwo;
cin >> oneOrTwo;
if(oneOrTwo == 1){
int smth;
cin >> smth;
}
else{
int l, r, m;
cin >> l >> r >> m;
m = min(r - l + 2 - m, m);
int a = (prefix2[l + m - 1] - prefix2[l - 1]) - (prefix[l + m - 1] - prefix[l - 1]) * (l - 1);
int b = (prefix[r - m] - prefix[l + m - 1]) * m;
int c = (prefix[r] - prefix[r - m]) * (r + 1) - (prefix2[r] - prefix2[r - m]);
cout << a + b + c << endl;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Incorrect |
6 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
58 ms |
916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
135 ms |
1928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |