# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
835347 | azatega | 사탕 분배 (IOI21_candies) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "candies.h"
#include <vector>
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l,
vector<int> r, vector<int> v) {
int n = c.size();
vector<int> s(n);
if(n <= 2000){
for(int i = 0; i < n; i++){
for(int j = 0; j < v.size(); j++){
if(i >= l[j] && i <= r[j]){
s[i] += v[j];
s[i] = max(s[i], 0);
s[i] = min(s[i], c[i]);
}
}
}
}else{
vector<long long> ch(n+5);
for(int j = 0; j < v.size(); j++){
ch[l[j]] += v[j];
ch[r[j] + 1] -= v[j];
}
long long curr = 0;
for(int i = 0; i < n; i++){
curr += ch[i];
s[i] = min(c[i], curr);
}
}
return s;
}