#include "candies.h"
#include <vector>
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l,
vector<int> r, vector<int> v) {
int q = l.size();
int n = c.size();
vector<int> adder (n,0);
vector<int> box(n,0);
for (int i = 0; i < q; i++)
{
adder[l[i]] += v[i];
if (r[i]+1 < n) adder[r[i]+1] -= v[i];
}
int add = 0;
for (int i = 0; i < n; i++)
{
add += adder[i];
if (add < 0)
{
box[i] = max(0, box[i] + add);
}
else {
box[i] = min(c[i], box[i] + add);
}
}
return box;
}
# |
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 |
103 ms |
8092 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 |
0 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 |
- |