#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vii vector<vi>
using ll=long long;
#define vl vector<long long>
ll np(int n){
while(n & (n-1))n++;
return n;
}
vl segtree;
void update(ll pos, ll l, ll r, ll x, ll y, ll value){
if(y<l)return;
if(x>r)return;
if(x>=l && y<=r){
segtree[pos]+=value;
return;
}
if(l==r)return;
update(pos*2,l,(l+r)/2,x,y,value);
update(pos*2+1,(l+r)+1,r,x,y,value);
}
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
std::vector<int> r, std::vector<int> v) {
int n = c.size();
int q=l.size();
int N=np(n);
segtree.resize(N);
std::vector<int> s(n);
for(int i=0;i<q;i++){
int x=l[i];
int y=r[i];
update(1,0,N-1,x,y,v[i]);
}
for(int i=1;i<N;i++){
segtree[2*i]+=segtree[i];
segtree[2*i+1]+=segtree[i];
}
for(int i=0;i<n;i++){
s[i]=segtree[N+i];
}
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
108 ms |
18916 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |