이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> sub1(std::vector<int> c, std::vector<int> l,
std::vector<int> r, std::vector<int> v) {
int n = c.size();
int q = l.size();
std::vector<int> s(n, 0);
for (int time = 0; time < q; time++) {
int L = l[time], R = r[time], V = v[time];
for (int i = L; i <= R; i++) {
if (V > 0) s[i] = min(c[i], s[i] + V);
else s[i] = max(0, s[i] + V);
}
}
return s;
}
std::vector<int> sub2(std::vector<int> c, std::vector<int> l,
std::vector<int> r, std::vector<int> v) {
int n = c.size();
int q = l.size();
std::vector<int> s(n, 0);
vector<long long> p(n + 1, 0);
for (int time = 0; time < q; time++) {
int L = l[time], R = r[time], V = v[time];
p[L] += V;
p[R + 1] -= V;
}
for (int i = 1; i <= n; i++) p[i] += p[i - 1];
for (int i = 0; i < n; i++) s[i] = min(1ll * c[i], p[i]);
return s;
}
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();
int q = l.size();
std::vector<int> s(n, 0);
if (n <= 2000 && q <= 2000) {
s = sub1(c, l, r, v);
}
else {
s = sub2(c, l, r, v);
}
return s;
}
# | 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... |