#include "candies.h"
#include<bits/stdc++.h>
using namespace std;
long long p[200005];
#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(); vector<int>ans(n);
int q = l.size();
if (n <= 2000 && q <= 2000) {
// subtask #1
for (int i = 0; i <= q; i++) {
for (int j = l[i]; j <= r[i]; j++) {
ans[j] = min(c[j], max(0, ans[j] + v[i]));
}
}
return ans;
}
else {
for (int i = 0; i <= q; i++) {
p[l[i]] += v[i];
p[r[i] + 1] -= v[i];
}
for (int i = 0; i <= q; i++) {
if (i) p[i] += p[i - 1];
ans[i] = min((long long)c[i], p[i]);
}
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
7 ms |
372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
130 ms |
8808 KB |
Output is correct |
2 |
Correct |
119 ms |
8816 KB |
Output is correct |
3 |
Correct |
118 ms |
8824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
70 ms |
10220 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Runtime error |
67 ms |
10168 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
7 ms |
372 KB |
Output is correct |
6 |
Correct |
130 ms |
8808 KB |
Output is correct |
7 |
Correct |
119 ms |
8816 KB |
Output is correct |
8 |
Correct |
118 ms |
8824 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Runtime error |
70 ms |
10220 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |