//pransh_8
// #include "candies.h"
#include <bits/stdc++.h>
using namespace std;
//Macros:
#define FOR(i, a, n) for(int i=a;i<n;++i)
#define FORR(i, a, n) for(int i=a;i>=n;--i)
/*------------------------------Code-Begins----------------------------------*/
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);
FOR(i,0,q) {
FOR(k,l[i],r[i]+1) {
if (v[i]>0)
ans[k]=min((long long)c[k],(long long)(ans[k]+v[i]));
else
ans[k]=max(0ll,(long long)(ans[k]+v[i]));
}
}
return ans;
}
/*
signed main() {
int n, q;
cin >> n;
vector<int> c(n);
FOR(i,0,n) cin >> c[i];
cin >> q;
vector<int> l(q), r(q), v(q);
FOR(i,0,q)
cin >> l[i] >> r[i] >> v[i];
vector<int> ans = distribute_candies(c,l,r,v);
FOR(i,0,n)
cout << ans[i] << ' ';
cout << endl;
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5025 ms |
7404 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
168 ms |
8276 KB |
Output is correct |
3 |
Correct |
158 ms |
5956 KB |
Output is correct |
4 |
Execution timed out |
5080 ms |
13396 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
401 ms |
7904 KB |
Output is correct |
4 |
Correct |
420 ms |
4028 KB |
Output is correct |
5 |
Execution timed out |
5024 ms |
10840 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Execution timed out |
5025 ms |
7404 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |