#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
#define pb push_back
typedef pair<int, int> pii;
#include "candies.h"
// #include <vector>
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();
int Q = l.size();
vector<int> s(N, 0);
rep(i,0,Q)
{
int li = l[i], ri = r[i], vv = v[i];
rep(j,li,ri+1)
{
if (vv > 0) s[j] = min(c[j], s[j] + vv);
else s[j] = max(0, s[j] + vv);
}
}
return s;
}
// int32_t main()
// {
// vector<int> ans = distribute_candies({10, 15, 13}, {0, 0}, {2, 1}, {20, -11});
// rep(i,0,ans.size())
// {
// cerr << ans[i] << " ";
// }
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5024 ms |
12108 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
163 ms |
8032 KB |
Output is correct |
3 |
Correct |
157 ms |
5900 KB |
Output is correct |
4 |
Execution timed out |
5042 ms |
13268 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
397 ms |
7664 KB |
Output is correct |
4 |
Correct |
350 ms |
3900 KB |
Output is correct |
5 |
Execution timed out |
5057 ms |
10840 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Execution timed out |
5024 ms |
12108 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |