# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
436352 | PiejanVDC | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int[] distribute_candies(int[] c, int[] l, int[] r, int[] v) {
int n = sizeof(c)/sizeof(c[0]), q = sizeof(v)/sizeof(v[0]);
int ans[n];
memset(ans,0,sizeof(ans));
for(int i = 0 ; i < q ; i++) {
for(int j = l[i] ; j <= r[i] ; j++) ans[j]=(v[i]>0?min(c[j],ans[j]+v[i]):max(0,ans[j]-v[i]));
}
return ans;
}