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