# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1058604 | qwusha | 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 "candies.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
typedef long double ld;
const ld eps = 1e-8;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const ll inf = 1e18;
const ll mod = 1e9 + 7;
vector<ll> distribute_candies(vector<ll> c, vector<ll> l, vector<ll> r, vector<ll> v) {
ll n = c.size();
vector<ll> res(n);
for (ll qw = 0; qw < l.size(); qw++) {
for (ll i = l[qw]; i <= r[qw]; i++) {
if (v[qw] > 0) {
res[i] = min(res[i] + v[qw], c[i]);
} else {
res[i] = max(res[i] + v[qw], 0ll);
}
}
}
return res;
}