#include "candies.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
struct A
{
long long l,r;
long long big,small;
long long add;
A *nxl,*nxr;
void build(long long ll,long long rr)
{
l=ll;
r=rr;
add=0;
if(rr==ll+1) return;
nxl=(A*) malloc(sizeof(A));
nxr=(A*) malloc(sizeof(A));
nxl->build(ll,(ll+rr)/2);
nxl->build((ll+rr)/2,rr);
}
void cha(long long ll,long long rr,long long con)
{
if(l==ll&&r==rr)
{
add+=con;
return;
}
if(rr<=(l+r)/2) nxl->cha(ll,rr,con);
else if(ll>=(l+r)/2) nxr->cha(ll,rr,con);
else
{
nxl->cha(ll,(ll+rr)/2,con);
nxr->cha((ll+rr)/2,rr,con);
}
}
long long Find(long long where)
{
if(where==l&&where+1==r) return add;
if(where<(l+r)/2) return add+nxl->Find(where);
else return add+nxr->Find(where);
}
};
vector < int > ans;
vector < int > distribute_candies(vector < int > c, vector < int > l,vector < int > r, vector < int > v)
{
long long N=(long long) c.size(),M=(long long) l.size(),i;
A* root=(A*) malloc(sizeof(A));
root->build(0,N);
for(i=0;i<M;i++) root->cha(l[i],r[i]+1,v[i]);
for(i=0;i<N;i++) ans.push_back((int) min((long long)c[i],root->Find(i)));
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
150 ms |
64480 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
588 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |