#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
using namespace std;
typedef long long ll;
int main(){
ll n, k;
cin >> n >> k;
vector<ll>a(n + 1);
for(int i = 1; i <= n; i++)
cin >> a[i];
vector<ll>pref(n + 1);
for(int i = 1; i <= n; i++)
pref[i] = pref[i - 1] + a[i];
ll q;
cin >> q;
while(q--){
ll type;
cin >> type;
if(type == 1){
ll p;
for(int i = 0; i < k; i++)
cin >> p;
}
else{
ll l, r, m;
cin >> l >> r >> m;
ll cnt = min(m, (r - l + 1) - m + 1);
// cout << cnt << endl;
ll ans = 0;
while(cnt > 0){
ans += pref[r] - pref[l - 1];
l++, r--;
cnt--;
}
cout << ans << endl;
}
}
return 0;
}
/*
3 1
3 4 5
1 2 90
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
5 ms |
340 KB |
Output is correct |
4 |
Correct |
9 ms |
340 KB |
Output is correct |
5 |
Correct |
12 ms |
412 KB |
Output is correct |
6 |
Correct |
15 ms |
444 KB |
Output is correct |
7 |
Correct |
19 ms |
424 KB |
Output is correct |
8 |
Correct |
24 ms |
424 KB |
Output is correct |
9 |
Correct |
37 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
872 KB |
Output is correct |
2 |
Correct |
189 ms |
1116 KB |
Output is correct |
3 |
Correct |
318 ms |
1392 KB |
Output is correct |
4 |
Correct |
990 ms |
2536 KB |
Output is correct |
5 |
Correct |
1509 ms |
3276 KB |
Output is correct |
6 |
Correct |
1343 ms |
3192 KB |
Output is correct |
7 |
Correct |
1133 ms |
3224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
270 ms |
1544 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |