#include "candies.h"
#include<bits/stdc++.h>
using namespace std;
int 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(c[i], p[i]);
}
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
7 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
129 ms |
8132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
74 ms |
10092 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Runtime error |
68 ms |
10096 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
7 ms |
332 KB |
Output is correct |
6 |
Incorrect |
129 ms |
8132 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |