# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
490830 | 2021-11-29T13:04:09 Z | Karuk | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; vector<int> 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]); } } vector<int>anss; for(int i:ans)anss.push_back(i); return anss; }