# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
633838 |
2022-08-23T09:50:36 Z |
uncripted |
Addk (eJOI21_addk) |
C++11 |
|
267 ms |
4092 KB |
#include<bits/stdc++.h>
using namespace std;
long long pre[100005];
long long n,k;
long long b1[100005],b2[100005];
void update(long long bit[], long long v, long long x){
while(v<=n){
bit[v]+=x;
v+=v&(-v);
}
}
void up(long long l, long long r, long long x){
update(b1, l, x);
update(b1, r+1, -x);
update(b2, l, (l-1)*x);
update(b2, r+1, -r*x);
}
long long presum(long long bit[], long long v){
long long s=0;
while(v>0){
s+=bit[v];
v-=v&(-v);
}
return s;
}
long long sum(long long l,long long 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];
long long 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;
k=1;
while(q--){
long long x;
cin>>x;
if(x==1){
long long b[k+1];
for(long long i=1; i<=k; i++){
cin>>b[i];
}
// up(b[k],n,a[b[1]]-a[b[k]]);
// for(long long 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 |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
5 ms |
340 KB |
Output is correct |
4 |
Correct |
8 ms |
416 KB |
Output is correct |
5 |
Correct |
10 ms |
420 KB |
Output is correct |
6 |
Correct |
12 ms |
476 KB |
Output is correct |
7 |
Correct |
18 ms |
516 KB |
Output is correct |
8 |
Correct |
23 ms |
484 KB |
Output is correct |
9 |
Correct |
23 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
944 KB |
Output is correct |
2 |
Correct |
74 ms |
1388 KB |
Output is correct |
3 |
Correct |
106 ms |
1796 KB |
Output is correct |
4 |
Correct |
173 ms |
2888 KB |
Output is correct |
5 |
Correct |
267 ms |
4092 KB |
Output is correct |
6 |
Correct |
229 ms |
3888 KB |
Output is correct |
7 |
Correct |
243 ms |
4056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
121 ms |
2164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |