#include "candies.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
using namespace std;
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(), m = l.size();
int allInc = 1;
for (int i = 0; i < m; i++) {
if (v[i] < 0) allInc = 0;
}
std::vector<int> s(n);
if (allInc) {
vi diff(n + 1);
for (int i = 0; i < m; i++) {
diff[l[i]] += v[i];
diff[r[i]+1] -= v[i];
}
for (int i = 0, sum = 0; i < n; i++) {
sum += diff[i];
s[i] = max(0, min(sum, c[i]));
}
} else {
for (int i = 0; i < m; i++) {
for (int j = l[i]; j <= r[i]; j++) {
s[j] = max(0, min(c[j], s[j] + v[i]));
}
}
}
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
104 ms |
8144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
192 ms |
4976 KB |
Output is correct |
3 |
Correct |
186 ms |
3756 KB |
Output is correct |
4 |
Execution timed out |
5050 ms |
7224 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
487 ms |
5024 KB |
Output is correct |
4 |
Correct |
458 ms |
2804 KB |
Output is correct |
5 |
Execution timed out |
5086 ms |
7244 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |