# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624405 | dnx04 | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KiB |
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/extc++.h"
using namespace std;
#define int long long
using Query = tuple<int, int, int>;
vector<int> sub1(const vector<int>& c, const vector<Query>& q) {
vector<int> a(c.size());
for (auto [l, r, v] : q) {
for (int i = l; i <= r; ++i) {
a[i] += v;
if (a[i] < 0) a[i] = 0;
if (a[i] > c[i]) a[i] = c[i];
}
}
return a;
}
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r,
vector<int> v) {
int n = c.size();
vector<Query> q;
for (int i = 0; i < n; ++i) q.emplace_back(l[i], r[i], v[i]);
return sub1(c, q);
}