# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
798824 | 2023-07-31T04:51:02 Z | khshg | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back vector<int> distribute_candies(vector<int> C, vector<int> L, vector<int> R, vector<int> V) { int Q = (int)L.size(), N = (int)C.size(); vector<long long> ans(N); for(int i = 0; i < Q; ++i) { ans[L[i]] += V[i]; if(R[i] + 1 < N) ans[R[i] + 1] -= V[i]; } for(int i = 1; i < N; ++i) { ans[i] += ans[i - 1]; } for(int i = 0; i < N; ++i) { ans[i] = min(ans[i], (long long)C[i]); } return ans; }