# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624405 | 2022-08-08T07:37:13 Z | dnx04 | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#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); }