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;
int p[200005];
#include <vector>
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
std::vector<int> r, std::vector<int> v) {
int n = c.size(); vector<int>ans(n);
int q = l.size();
if (n <= 2000 && q <= 2000) {
// subtask #1
for (int i = 0; i <= q; i++) {
for (int j = l[i]; j <= r[i]; j++) {
ans[j] = min(c[j], max(0, ans[j] + v[i]));
}
}
return ans;
}
else {
for (int i = 0; i <= q; i++) {
p[l[i]] += v[i];
p[r[i] + 1] -= v[i];
}
for (int i = 0; i <= q; i++) {
if (i) p[i] += p[i - 1];
ans[i] = min(c[i], p[i]);
}
return ans;
}
}
# | 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... |