This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> distribute_candies(vector<int> c, vector<int> l,
vector<int> r, vector<int> v) {
int n = c.size();
int q = v.size();
vector<int> ans(n, 0);
vector<ll> diff(n + 1, 0);
for(int i = 0; i < q; i++) {
diff[l[i]] = diff[l[i]] + v[i];
diff[r[i] + 1] = diff[r[i] + 1] - v[i];
}
ll sum = 0;
for(int i = 0; i < n; i++) {
sum = sum + diff[i];
ans[i] = min((ll) c[i], sum);
}
return ans;
}
# | 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... |