#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> distribute_candies(vector<int> c,vector<int> l, vector<int> r, vector<int> v) {
int n = c.size();
vector<int> s(n);
int q=v.size();
vector<long long> delta(n+1);
for(int i=0;i<=n;i++) {
delta[i]=0;
}
for(int i=0;i<q;i++) {
delta[l[i]]+=v[i];
delta[r[i]+1]-=v[i];
}
long long val=0;
for(int i=0;i<n;i++) {
val+=delta[i];
s[i]=min((long long)c[i],val);
}
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
130 ms |
8796 KB |
Output is correct |
2 |
Correct |
117 ms |
8800 KB |
Output is correct |
3 |
Correct |
139 ms |
8880 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 |
1 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 |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |