#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int n, q;
long long arr[N], capacity[N];
vector<int> distribute_candies(vector<int> c, vector<int> l,
vector<int> r, vector<int> v) {
n = c.size(), q = l.size();
for(int i=1 ; i<=n ; i++) capacity[i] = c[i-1];
for(int i=0 ; i<q ; i++)
{
int a = l[i]+1, b = r[i]+1, c = v[i];
if(c < 0) return {};
arr[a] += c;
arr[b+1] -= c;
}
for(int i=1 ; i<=n ; i++) arr[i] += arr[i-1];
vector<int> ret;
for(int i=1 ; i<=n ; i++) ret.push_back(min(arr[i], capacity[i]));
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
10860 KB |
Output is correct |
2 |
Correct |
117 ms |
10844 KB |
Output is correct |
3 |
Correct |
118 ms |
10808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |