# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
549445 | 2022-04-15T20:08:30 Z | kilikuma | 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) / sizeof(c[0]); int Q = sizeof(l) / sizeof(l[0]); int S[N + 1] = {0}; for (int i = 0; i < Q; i ++) { for (int j = l[i]; j <= r[i]; j ++) { if (v[i] < 0) S[j] = min(c[j], S[j] + v[i]); else S[j] = max(0, S[j] + v[i]); } } return S; }