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>
#define ll long long
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l,
vector<int> r, vector<int> v)
{
int n = c.size(), q = l.size();
if (q <= 2000)
{
vector<int> s(n, 0);
for (int i = 0; i < q; i++)
{
for (int j = l[i]; j <= r[i]; j++)
s[j] = max(0, min(c[j], s[j] + v[i]));
}
return s;
}
else
{
vector<ll> s(n + 1);
for (int i = 0; i < q; i++)
s[l[i]] += v[i], s[r[i] + 1] -= v[i];
for (int i = 1; i <= n; i++)
s[i] += s[i - 1];
for (int i = 0; i < n; i++)
c[i] = min((ll)c[i], s[i]);
return c;
}
return {};
}
# | 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... |