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