# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
490829 | 2021-11-29T13:03:11 Z | Karuk | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; vector<long long> distribute_candies(vector<long long> c, vector<long long> l, vector<long long> r, vector<long long> v) { long long n=sizeof(c); long long q=sizeof(l); vector<long long>ans(n,0); for(long long i=0;i<q;i++) { for(long long j=l[i];j<=r[i];j++) { if(v[i]>0)ans[j]=min(c[j],ans[j]+v[i]); else ans[j]=max((long long) 0,ans[j]+v[i]); } } return ans; }