#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;
#include "candies.h"
#include <vector>
llo cur[200001];
llo tree[200001];
void u(llo i,llo j){
while(i<=200000){
tree[i]+=j;
i+=(i&-i);
}
}
llo ss(llo i){
llo su=0;
while(i>0){
su+=tree[i];
i-=(i&-i);
}
return su;
}
std::vector<int> distribute_candies(vector<int> it,vector<int> ll,
vector<int> rr,vector<int> aa) {
llo n=it.size();
llo q=ll.size();
for(llo i=0;i<n;i++){
cur[i]=0;
}
for(llo i=0;i<=200000;i++){
tree[i]=0;
}
for(llo i=0;i<q;i++){
u(ll[i]+1,aa[i]);
u(rr[i]+2,-aa[i]);
/*for(llo j=ll[i];j<=rr[i];j++){
cur[j]+=aa[i];
cur[j]=max(cur[j],0);
cur[j]=min(cur[j],it[j]);
}*/
}
vector<int> ans;
for(llo i=0;i<n;i++){
ans.pb((int)min((llo)it[i],ss(i+1)));
//cout<<ss(i+1)<<":";
}
//cout<<endl;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1740 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1868 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
10812 KB |
Output is correct |
2 |
Correct |
141 ms |
10844 KB |
Output is correct |
3 |
Correct |
128 ms |
10808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1740 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1868 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |