# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
490533 | 2021-11-27T20:23:09 Z | nickmet2004 | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include<bits/stdc++.h> #include "candies.h" #define ve vector<int> using namespace std; v ans; ve distribute_candies(ve c, ve l, ve r, ve v){ int n =c.size() , q = v.size(); ans.resize(n , 0); for(int i = 0; i < q; ++i){ ans[l[i]] += v[i]; ans[r[i] + 1] -= v[i]; } for(int i = 1; i < n; ++i) ans[i] += ans[i - 1]; for(int i = 0;i < n; ++i) ans[i] = min(ans[i] , c[i]); return ans; }