#include <bits/stdc++.h>
using namespace std;
#define N 10000
#define ll long long
vector<int> tree(2*N,0);
int n;
void build(vector<int> lista){
for(int i=0;i<n;i++){
tree[n+i]=lista[i];
}
for (int i=n-1;i>0;i--){
tree[i]=tree[i<<1]+tree[i<<1 | 1];
}
}
void update(int p, int value){
tree[p]=value;
p+=n;
tree[p]=value;
for(p/=2;p>0;p/=2){
tree[p]=tree[2*p]+tree[p*2+1];
}
}
int sum(int l, int r){
int res = 0;
for (l+=n,r+=n;l<r;l>>=1,r>>=1)
{
if (l&1)
res += tree[l++];
if (r&1)
res += tree[--r];
}
return res;
}
int main(){
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
int q,k;
cin>>n>>k;
vector<int> lista(n);
for(int i=0;i<n;i++){
cin>>lista[i];
}
build(lista);
cin>>q;
for(int i=0;i<q;i++){
int c;
cin>>c;
if(c==1){
int a;
cin>>a;
int first=tree[a+n-1];
int b=a;
for(int i=0;i<k-1;i++){
int d=b;
cin>>b;
update(d-1,tree[b-1+n]);
}
update(b-1,first);
}
else if(c==2){
int a,b,m;
cin>>a>>b>>m;
int f=0;
for(int j=a;j<=b-m+1;j++){
f+=sum(j-1,j+m-1);
}
cout<<f<<'\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2068 ms |
1028 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
2004 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |