#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forr(X) for(int i = 0; i<X; i++)
#pragma GCC optimize("Ofast")
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 <int> pre(n+1, 0), ans(n, 0);
forr(q){
pre[l[i]]+=v[i];
pre[r[i]+1]-=v[i];
}
ans[0] = pre[0];
for(int i=1; i<n; i++){
ans[i] = ans[i-1] + pre[i];
}
forr(n){
ans[i] = max(0, ans[i]);
ans [i] = min(c[i], ans[i]);
}
return ans;
}
/*int main(){
vector <int> a = distribute_candies({10, 15, 13}, {0, 0}, {2, 1}, {20, -11});
for(auto it:a)cout<<it<<" ";
}*/
# |
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 |
124 ms |
8132 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 |
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 |
- |