#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n,k;
cin>>n>>k;
ll a[n+1],p1[n+1],p2[n+1];
a[0]=p1[0]=p2[0]=0;
for(int i=1;i<=n;i++){
cin>>a[i];
p1[i]=p1[i-1]+a[i];
p2[i]=p2[i-1]+p1[i];
}
int q;
cin>>q;
while(q--){
int t;
cin>>t;
if(t==2){
int l,r,m;
cin>>l>>r>>m;
ll ans=p2[r]-p2[l+m-2]-p2[r-m];
if(l>1)ans+=p2[l-2];
cout<<ans<<'\n';
}else{
int x[k];
for(int i=0;i<k;i++)cin>>x[i];
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
348 KB |
Output is correct |
4 |
Correct |
6 ms |
344 KB |
Output is correct |
5 |
Correct |
7 ms |
652 KB |
Output is correct |
6 |
Correct |
13 ms |
604 KB |
Output is correct |
7 |
Correct |
11 ms |
604 KB |
Output is correct |
8 |
Correct |
12 ms |
812 KB |
Output is correct |
9 |
Correct |
17 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
1616 KB |
Output is correct |
2 |
Correct |
53 ms |
2132 KB |
Output is correct |
3 |
Correct |
71 ms |
2844 KB |
Output is correct |
4 |
Correct |
124 ms |
4692 KB |
Output is correct |
5 |
Correct |
176 ms |
6740 KB |
Output is correct |
6 |
Correct |
159 ms |
6424 KB |
Output is correct |
7 |
Correct |
160 ms |
6480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
89 ms |
3936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |