#include "candies.h"
#include <vector>
using namespace std;
using ll = long long;
const int MAXN = 2e5 + 123;
const ll INF = 1e18 + 177013;
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size();
int q = l.size();
vector<int> s(n, 0);
for(int i = 0; i < q; ++i)
++r[i];
if(n <= 2000){
for(int qi = 0; qi < q; ++qi){
for(int i = l[qi]; i < r[qi]; ++i){
s[i] += v[qi];
s[i] = max(s[i], 0);
s[i] = min(s[i], c[i]);
}
}
return s;
}
bool isv_positive = true;
for(int i = 0; i < q; ++i)
isv_positive &= v[i] >= 0;
if(isv_positive){
vector<ll> pf(n + 1, 0);
for(int qi = 0; qi < q; ++qi){
pf[l[qi]] += v[qi];
pf[r[qi]] -= v[qi];
}
ll sm = 0;
for(int i = 0; i < n; ++i){
sm += pf[i];
s[i] = int(min(sm, 1ll * c[i]));
}
return s;
}
return s;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
4 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
133 ms |
10776 KB |
Output is correct |
2 |
Correct |
133 ms |
9924 KB |
Output is correct |
3 |
Correct |
127 ms |
9868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
253 ms |
7052 KB |
Output is correct |
3 |
Incorrect |
65 ms |
4624 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
280 KB |
Output is correct |
3 |
Correct |
601 ms |
7068 KB |
Output is correct |
4 |
Incorrect |
55 ms |
3780 KB |
Output isn't correct |
5 |
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 |
4 ms |
332 KB |
Output is correct |
6 |
Correct |
133 ms |
10776 KB |
Output is correct |
7 |
Correct |
133 ms |
9924 KB |
Output is correct |
8 |
Correct |
127 ms |
9868 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
253 ms |
7052 KB |
Output is correct |
11 |
Incorrect |
65 ms |
4624 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |