이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
using namespace std;
#pragma GCC target "avx2"
#pragma GCC optimize "Ofast"
typedef vector<int> vi;
#define SZ(v) ((int) (v).size())
#define min(a, b) ((a)<(b)?(a):(b))
#define max(a, b) ((a)<(b)?(b):(a))
const int MN = 2e5;
const int BSZ = 2e3;
int n, q;
int arr[BSZ], cap[BSZ];
vi distribute_candies(vi cIn, vi lIn, vi rIn, vi vIn){
n = SZ(cIn);
q = SZ(lIn);
vi res(n);
for(int bl = 0; bl < n; bl += BSZ){
int br = min(n, bl+BSZ);
for(int i = bl; i < br; i++) arr[i-bl] = 0, cap[i-bl] = cIn[i];
for(int qi = 0; qi < q; qi++){
int l = max(0, lIn[qi]-bl), r = min(br, rIn[qi]+1)-bl, v = vIn[qi];
if(v < 0) for(int j = l; j < r; j++) arr[j] = max(arr[j] + v, 0);
else for(int j = l; j < r; j++) arr[j] = min(arr[j] + v, cap[j]);
}
for(int i = bl; i < br; i++) res[i] = arr[i-bl];
}
return res;
}
| # | 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... |