#include "candies.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
using namespace std;
const int N = 200004;
int a[N], ll[N], rr[N], cc[N], vv[N];
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 q = (int)l.size();
for (int i = 0; i < q; i++) {
ll[i] = l[i];
rr[i] = r[i];
vv[i] = v[i];
}
for (int i = 0; i < n; i++)
cc[i] = c[i];
for (int i = 0; i < q; i++) {
for (int j = ll[i]; j <= rr[i]; j++) {
a[j] += vv[i];
a[j] = Min (a[j], cc[j]);
a[j] = Max (a[j], 0);
}
}
std::vector<int> s(n);
for (int i = 0; i < n; i++)
s[i] = a[i];
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1971 ms |
11344 KB |
Output is correct |
2 |
Correct |
1988 ms |
15456 KB |
Output is correct |
3 |
Correct |
2054 ms |
15296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
75 ms |
9968 KB |
Output is correct |
3 |
Correct |
54 ms |
7880 KB |
Output is correct |
4 |
Correct |
1926 ms |
14716 KB |
Output is correct |
5 |
Correct |
1950 ms |
17492 KB |
Output is correct |
6 |
Correct |
1853 ms |
18004 KB |
Output is correct |
7 |
Correct |
1842 ms |
17424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
72 ms |
9736 KB |
Output is correct |
4 |
Correct |
74 ms |
6468 KB |
Output is correct |
5 |
Correct |
4893 ms |
13440 KB |
Output is correct |
6 |
Execution timed out |
5032 ms |
14676 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1971 ms |
11344 KB |
Output is correct |
7 |
Correct |
1988 ms |
15456 KB |
Output is correct |
8 |
Correct |
2054 ms |
15296 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
75 ms |
9968 KB |
Output is correct |
11 |
Correct |
54 ms |
7880 KB |
Output is correct |
12 |
Correct |
1926 ms |
14716 KB |
Output is correct |
13 |
Correct |
1950 ms |
17492 KB |
Output is correct |
14 |
Correct |
1853 ms |
18004 KB |
Output is correct |
15 |
Correct |
1842 ms |
17424 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
72 ms |
9736 KB |
Output is correct |
19 |
Correct |
74 ms |
6468 KB |
Output is correct |
20 |
Correct |
4893 ms |
13440 KB |
Output is correct |
21 |
Execution timed out |
5032 ms |
14676 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |