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 <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... |