#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>ft;
void add(int l, int v, int n) {
for(;l<=n;l+=l&-l) ft[l]+=v;
}
void RangeQuery(int l, int r, int n, int v) {
add(l, v, n); add(r+1, -v, n);
}
int sum(int l) {
int res=0;
for(;l>0;l-=l&-l) res+=ft[l];
return res;
}
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = (int)c.size(); int q=(int)v.size(); vector<int> s(n, 0); ft.assign(n+1, 0);
for(int k=0;k<q;k++) {
int i=l[k], j=r[k], x=v[k]; i++; j++;
RangeQuery(i, j, n, x);
}
for(int i=1;i<=n;i++) {
s[i-1]=sum(i);
if(s[i-1]>c[i-1]) s[i-1]=c[i-1];
}
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
138 ms |
12880 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |