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