#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, m, q, k, x, y, a, b, c;
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
n = c.size();
q = v.size();
vector<int> ans(n);
if (n <= 2000) {
for (int i = 0; i < q; i++) {
for (int j = l[i]; j <= r[i]; j++) {
ans[j] += v[i];
ans[j] = max(0, ans[j]);
ans[j] = min(c[j], ans[j]);
}
}
return ans;
}
if (*min_element(v.begin(), v.end()) >= 0) {
vector<ll> ev(n + 1);
for (int i = 0; i < q; i++) {
ev[l[i]] += v[i];
ev[r[i] + 1] -= v[i];
}
ll cnt = 0;
for (int i = 0; i < n; i++) {
cnt += ev[i];
ans[i] = min((ll)c[i], cnt);
}
return ans;
}
}
Compilation message
candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
35 | }
| ^
# |
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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
13800 KB |
Output is correct |
2 |
Correct |
63 ms |
12880 KB |
Output is correct |
3 |
Correct |
63 ms |
12880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
134 ms |
8144 KB |
Output is correct |
3 |
Incorrect |
64 ms |
6484 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
343 ms |
7716 KB |
Output is correct |
4 |
Incorrect |
35 ms |
5424 KB |
Output isn't correct |
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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
77 ms |
13800 KB |
Output is correct |
7 |
Correct |
63 ms |
12880 KB |
Output is correct |
8 |
Correct |
63 ms |
12880 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
134 ms |
8144 KB |
Output is correct |
11 |
Incorrect |
64 ms |
6484 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |