#include <bits/stdc++.h>
#include "candies.h"
using namespace std;
#define ll unsigned long long
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size(), q = l.size();
vector<int> s(n);
ll prf[n + 1];
memset(prf, 0, sizeof(prf));
for (int i = 0; i < q; i++) prf[l[i]] += v[i], prf[r[i] + 1] -= v[i];
ll sum = 0;
for (int i = 0; i < n; i++) {
sum += prf[i];
s[i] = min(sum, (ll) c[i]);
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |