#include <bits/stdc++.h>
#define nikah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
const ll maxn = 1e5+7;
using namespace std;
ll n,q,k;
ll a[maxn], pref[maxn];
int main() {
nikah
cin>>n>>k;
for (ll i=1; i<=n; i++) {
cin>>a[i];
pref[i] = a[i] + pref[i-1];
}
cin>>q;
while (q--) {
ll mode; cin>>mode;
if (mode == 2) {
ll l,r,m; cin>>l>>r>>m;
ll ans = 0;
m = min(m, r-l+2-m);
for (ll i=1; i<=m; i++) {
ans += (pref[r] - pref[l-1]);
l++; r--;
}
cout<<ans<<endl;
} else {
ll x; cin>>x;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
348 KB |
Output is correct |
6 |
Correct |
9 ms |
604 KB |
Output is correct |
7 |
Correct |
12 ms |
604 KB |
Output is correct |
8 |
Correct |
15 ms |
604 KB |
Output is correct |
9 |
Correct |
29 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
824 KB |
Output is correct |
2 |
Correct |
160 ms |
1360 KB |
Output is correct |
3 |
Correct |
254 ms |
1628 KB |
Output is correct |
4 |
Correct |
713 ms |
2384 KB |
Output is correct |
5 |
Correct |
1207 ms |
4176 KB |
Output is correct |
6 |
Correct |
1121 ms |
5508 KB |
Output is correct |
7 |
Correct |
883 ms |
5716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |