# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061337 | TheQuantiX | Distributing Candies (IOI21_candies) | C++17 | 343 ms | 13800 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;
using ll = long long;
ll n, m, q, k, x, y, a, b, c;
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
n = c.size();
q = v.size();
vector<int> ans(n);
if (n <= 2000) {
for (int i = 0; i < q; i++) {
for (int j = l[i]; j <= r[i]; j++) {
ans[j] += v[i];
ans[j] = max(0, ans[j]);
ans[j] = min(c[j], ans[j]);
}
}
return ans;
}
if (*min_element(v.begin(), v.end()) >= 0) {
vector<ll> ev(n + 1);
for (int i = 0; i < q; i++) {
ev[l[i]] += v[i];
ev[r[i] + 1] -= v[i];
}
ll cnt = 0;
for (int i = 0; i < n; i++) {
cnt += ev[i];
ans[i] = min((ll)c[i], cnt);
}
return ans;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |