#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size(), q = (int)l.size();
vector<int> s;
if (n <= 2000 && q <= 2000) {
s.resize(n);
for (int i = 0; i < q; i++) {
for (int j = l[i]; j <= r[i]; j++) {
s[j] += v[i];
if (s[j] < 0) s[j] = 0;
if (s[j] > c[j]) s[j] = c[j];
}
}
} else {
vector<long long> pr(n + 1);
for (int i = 0; i < q; i++) {
pr[l[i]] += (long long) v[i];
pr[r[i] + 1] -= (long long) v[i];
}
for (int i = 0; i < n; i++) pr[i + 1] += pr[i];
for (int i = 0; i < n; i++) {
s[i] = c[i] < pr[i] ? c[i] : pr[i + 1];
}
}
return s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
6 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
85 ms |
21076 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Runtime error |
56 ms |
13000 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
53 ms |
12624 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
6 ms |
340 KB |
Output is correct |
6 |
Runtime error |
85 ms |
21076 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |