#include "candies.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int n,q;
std::vector<int32_t> distribute_candies(std::vector<int32_t> c, std::vector<int32_t> l,
std::vector<int32_t> r, std::vector<int32_t> v) {
n=c.size();
q=l.size();
vector<int> a(n,0);
vector<int32_t> ans(n,0);
for (int i=0;i<q;i++){
a[l[i]]+=v[i];
if (r[i]<n-1) a[r[i]+1]-=v[i];
}
for (int i=0;i<n;i++){
if (i) a[i]+=a[i-1];
ans[i]=min(a[i],(int)c[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 |
69 ms |
8936 KB |
Output is correct |
2 |
Correct |
64 ms |
12880 KB |
Output is correct |
3 |
Correct |
63 ms |
12772 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 |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |