# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
516599 | 2022-01-21T14:51:16 Z | marat0210 | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include <candies.h> #include <bits/stdc++.h> using namespace std; std::vector <long long> distribute_candies(std::vector <long long> c, std::vector <long long> l, std::vector <long long> r, std::vector <long long> v) { long long n = c.size(); vector <long long> res(n); long long q = l.size(); for (int i = 0; i < q; ++i) { long long left = l[i], right = r[i], add = v[i]; for (int j = left; j <= right; ++j) { if (add < 0) { res[j] = max(0ll, res[j] + add); } else { res[j] = min(c[j], res[j] + add); } } } return res; }