#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 |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2464 ms |
7364 KB |
Output is correct |
2 |
Correct |
2425 ms |
7372 KB |
Output is correct |
3 |
Correct |
2427 ms |
7360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
68 ms |
4956 KB |
Output is correct |
3 |
Correct |
65 ms |
3796 KB |
Output is correct |
4 |
Correct |
2244 ms |
7364 KB |
Output is correct |
5 |
Correct |
2281 ms |
7360 KB |
Output is correct |
6 |
Correct |
2244 ms |
7372 KB |
Output is correct |
7 |
Correct |
2162 ms |
7360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
103 ms |
5028 KB |
Output is correct |
4 |
Correct |
103 ms |
2840 KB |
Output is correct |
5 |
Execution timed out |
5076 ms |
7264 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
2464 ms |
7364 KB |
Output is correct |
7 |
Correct |
2425 ms |
7372 KB |
Output is correct |
8 |
Correct |
2427 ms |
7360 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
68 ms |
4956 KB |
Output is correct |
11 |
Correct |
65 ms |
3796 KB |
Output is correct |
12 |
Correct |
2244 ms |
7364 KB |
Output is correct |
13 |
Correct |
2281 ms |
7360 KB |
Output is correct |
14 |
Correct |
2244 ms |
7372 KB |
Output is correct |
15 |
Correct |
2162 ms |
7360 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
103 ms |
5028 KB |
Output is correct |
19 |
Correct |
103 ms |
2840 KB |
Output is correct |
20 |
Execution timed out |
5076 ms |
7264 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |