#include "candies.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200'010;
long long fen[MAXN];
void upd(int at, long long val) {
at++;
while(at < MAXN) {
fen[at]+=val;
at+=at&(-at);
}
}
long long query(int r) {
long long sum = 0;
r++;
while(r > 0) {
sum+=fen[r];
r-=r&(-r);
}
return sum;
}
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size();
vector<int> s(n);
for(int i = 0;i<MAXN;i++)fen[i] =0;
for(int i = 0;i<n;i++) {
for(int j = l[i];j<=r[i];j++) {
if(v[i] > 0) {
s[j] = min(s[j] + v[i], c[j]);
}
else {
s[j] = max(s[j] + v[i], 0);
}
}
}
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1748 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Incorrect |
1 ms |
1852 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5039 ms |
8892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
3540 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1868 KB |
Output is correct |
2 |
Runtime error |
3 ms |
3668 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1748 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Incorrect |
1 ms |
1852 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |