# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
480612 | Haidara | 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(vector<int> c,vector<int> l,vector<int> r, vector<int> v)
{
int n=l.size();
int res[c.size()];
for(int i=0;i<c.size();i++)
res[i]=0;
for(int i=0;i<n;i++)
{
for(int j=l[i];j<=r[i];j++)
{
if(v[i]>0)
res[j]=min(res[j]+v[i],c[j]);
else
res[j]=max(0,res[j]-v[i]);
}
}
return res;
}