# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
502562 |
2022-01-06T09:02:49 Z |
uncripted |
Addk (eJOI21_addk) |
C++11 |
|
147 ms |
3328 KB |
#include<bits/stdc++.h>
using namespace std;
long long pre[100005];
long long n,k;
int b1[100005],b2[100005];
void update(int bit[], int v, int x){
while(v<=n){
bit[v]+=x;
v+=v&(-v);
}
}
void up(int l, int r, int x){
update(b1, l, x);
update(b1, r+1, -x);
update(b2, l, (l-1)*x);
update(b2, r+1, -r*x);
}
int presum(int bit[], int v){
int s=0;
while(v>0){
s+=bit[v];
v-=v&(-v);
}
return s;
}
int sum(int l,int r){
return presum(b1, r)*r-presum(b2, r)-(presum(b1, l-1)*(l-1)-presum(b2, l-1));
}
int main(){
cin>>n>>k;
long long a[n+1];
int prefix=0;
for(long long i=1; i<=n; i++){
cin>>a[i];
prefix+=a[i];
up(i,i,prefix);
}
long long q;
cin>>q;
while(q--){
long long x;
cin>>x;
if(x==1){
int b[k+1];
for(int i=1; i<=k; i++){
cin>>b[i];
}
up(b[k],n,a[b[k]]-a[b[1]]);
for(int i=1; i<k; i++){
up(b[i],n, a[b[i+1]]-a[b[i]] );
}
continue;
}
long long l,r,m;
cin>>l>>r>>m;
long long s=0;
s+=sum(l+m-1, r);
s-=sum(l-1, r-m);
cout<<s<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Incorrect |
5 ms |
312 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
1184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
147 ms |
3328 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |