# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
742846 | t6twotwo | 사탕 분배 (IOI21_candies) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
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 m = v.size();
for (auto &x : r) {
x++;
}
if (n <= 2000 && q <= 2000) {
vector<int> a(n);
for (int i = 0; i < m; i++) {
for (int j = l[i]; j < r[i]; j++) {
a[j] = min(c[j], max(a[j] + v[j], 0));
}
}
return a;
}
if (*min_element(v.begin(), v.end()) > 0) {
vector<ll> pfs(n + 1);
for (int i = 0; i < m; i++) {
pfs[l[i]] -= v[i];
pfs[r[i]] += v[i];
}
for (int i = 0; i < n; i++) {
pfs[i + 1] += pfs[i];
}
vector<int> a(n);
for (int i = 0; i < n; i++) {
a[i] = min(1LL * c[i], pfs[i]);
}
return a;
}
return {};
}