# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1021448 | 2024-07-12T18:24:41 Z | Wael | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include "candies.h" #include <bits/stdc++.h> #include "grader.cpp" using namespace std; 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> s(n); for (int j = 0; j < q; ++j) { for (int i = l[j]; i <= r[j]; ++i) { s[i] += v[j]; s[i] = min(s[i], c[i]); s[i] = max(s[i], 0); } } return s; }