#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9;
vector <int> prefix_sum(vector <int> c, vector<int>l, vector<int> r, vector<int> v)
{
int n = c.size(), q = v.size();
vector <int> prefix(n + 1);
for (int i = 0; i < q; i++) {
prefix[l[i]] += v[i];
prefix[r[i] + 1] -= v[i];
}
for (int i = 1; i <n; i++) {
prefix[i] = min(prefix[i - 1] + prefix[i], inf);
prefix[i - 1] = min(c[i - 1], prefix[i - 1]);
}
prefix.erase(prefix.end() - 1);
return prefix;
}
vector<int> distribute_candies(vector <int> c, vector<int> l, vector<int> r, vector<int> v)
{
vector <int> s = prefix_sum(c, l, r, v);
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
15320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |