#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();
int q=l.size();
vector<long long>add(n+1,0);
vector<long long>ans(n,0);
for(int i=0;i<q;i++)
{
add[l[i]]+=v[i];
add[r[i]+1]-=v[i];
}
for(int i=0;i<n;i++)
{
if(i!=0)ans[i]=ans[i-1];
ans[i]+=add[i];
}
for(int i=0;i<n;i++)
{
if(ans[i]>c[i])ans[i]=c[i];
}
vector<int>ca;
for(long long i:ans)ca.push_back(i);
return ca;
}
# |
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 |
98 ms |
10796 KB |
Output is correct |
2 |
Correct |
104 ms |
14908 KB |
Output is correct |
3 |
Correct |
98 ms |
14752 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 |
- |