# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
549450 | 2022-04-15T20:16:51 Z | kilikuma | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "candies.h" 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 = l.size(); vector<int> S; for (int i = 0; i < N + 1; i ++) S.push_back(0); for (int i = 0; i < Q; i ++) { for (int j = l[i]; j <= r[i]; j ++) { if (v[i] < 0) S[j] = min(c[j], S[j] + v[i]); else S[j] = max(0, S[j] + v[i]); } } return S; }