# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
571217 |
2022-06-01T14:53:25 Z |
Adnanboi |
Addk (eJOI21_addk) |
C++14 |
|
8 ms |
2788 KB |
#include <bits/stdc++.h>
using namespace std;
#define N 10000
#define ll long long
vector<long long> tree(2*N,0);
long long n;
void build(vector<long long> lista){
for(long long i=0;i<n;i++){
tree[n+i]=lista[i];
}
for (long long i=n-1;i>0;i--){
tree[i]=tree[i<<1]+tree[i<<1 | 1];
}
}
void update(long long p, long long 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];
}
}
long long sum(long long l, long long r){
long long 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);
long long q,k;
cin>>n>>k;
vector<long long> lista(n);
for(long long i=0;i<n;i++){
cin>>lista[i];
}
build(lista);
cin>>q;
for(long long i=0;i<q;i++){
long long c;
cin>>c;
if(c==1){
long long a;
cin>>a;
long long first=tree[a+n-1];
long long b=a;
for(long long i=0;i<k-1;i++){
long long d=b;
cin>>b;
update(d-1,tree[b-1+n]);
}
update(b-1,first);
}
else if(c==2){
long long a,b,m;
cin>>a>>b>>m;
long long f=0;
for(long long j=a;j<=b-m+1;j++){
f+=sum(j-1,j+m-1);
}
cout<<f<<'\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
1788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
2788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |