#include<bits/stdc++.h>
#include "candies.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
vector<int>distribute_candies(vector<int>c,vector<int>l,vector<int>r,vector<int>v){
int n=c.size(),q=l.size();
vector<int>ans(n,0);
vector<ll>add(n,0),sub(n,0);
for(int i=0;i<q;i++){
add[l[i]]+=v[i];
sub[r[i]]+=v[i];
}
ll cur=0;
for(int i=0;i<n;i++){
cur+=add[i];
if(cur>c[i]){
ans[i]=c[i];
}
else{
ans[i]=(int)cur;
}
cur-=sub[i];
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
10576 KB |
Output is correct |
2 |
Correct |
83 ms |
14512 KB |
Output is correct |
3 |
Correct |
80 ms |
14300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |