#include "candies.h"
#include<bits/stdc++.h>
#define vi vector<int>
using namespace std;
#define ll long long
#define vll vector<ll>
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
std::vector<int> r, std::vector<int> v) {
int n = c.size();
vi ans(n);
int m = r.size();
vll his(n+1);
for(int i = 0; i < m; i++){
his[l[i]]+=v[i];
his[r[i]+1]-=v[i];
}
ll sum = 0;
for(int i = 0; i < n; i++){
sum+=his[i];
ans[i] = min((ll)c[i],sum);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
92 ms |
8944 KB |
Output is correct |
2 |
Correct |
66 ms |
12884 KB |
Output is correct |
3 |
Correct |
65 ms |
12884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |