# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
549437 | kilikuma | 사탕 분배 (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]);
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;
}