# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
500210 | 2021-12-30T13:12:17 Z | sazid_alam | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include "candies.h" #include <bits/stdc++.h> using namespace std; typedef int long long; vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(); vector<int> sum(n + 1, 0); for(int i = 0; i < v.size(); i++){ sum[l[i]] += v[i]; sum[r[i] + 1] -= v[i]; } for(int i = 1; i < n; i++) sum[i] += sum[i - 1]; for(int i = 0; i < n; i++) c[i] = min(c[i], sum[i]); return c; }