#include <bits/stdc++.h>
using namespace std;
typedef int ll;
vector<ll> distribute_candies(vector<ll> c, vector<ll> l, vector<ll> r, vector<ll> v) {
ll n = c.size(), q = v.size();
bool non_neg = true;
for (ll val: v) if (val < 0) {
non_neg = false;
break;
}
if (non_neg == true) {
vector<ll> diff(n + 1, 0);
for (ll i = 0; i < q; i++) {
diff[l[i]] += v[i];
diff[r[i] + 1] -= v[i];
}
for (ll i = 1; i < n; i++) {
diff[i] += diff[i - 1];
}
vector<ll> res(n, 0);
for (ll i = 0; i < n; i++) {
res[i] = min(c[i], diff[i]);
}
return res;
}
if (n <= 2000 && q <= 2000) {
vector<ll> res(n, 0);
for (ll i = 0; i < q; i++) {
for (ll j = l[i]; j <= r[i]; j++) {
res[j] = max(min(res[j] + v[i], c[j]), (ll)0);
}
}
return res;
}
return vector<ll>();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
72 ms |
13012 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
36 ms |
8016 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
30 ms |
7516 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |