#include "candies.h"
#include <vector>
using namespace std;
typedef long long ll;
vector<int> distribute_candies(vector<int> cInt, vector<int> lInt, vector<int> rInt, vector<int> vInt) {
int n = cInt.size();
int q = vInt.size();
vector<ll> s(n+1), c(n), l(q), r(q), v(q);
for(int i = 0; i < n; i++) {
c[i] = cInt[i];
}
for(int i = 0; i < q; i++) {
l[i] = lInt[i];
r[i] = rInt[i];
v[i] = vInt[i];
}
bool subtask2 = true, subtask3 = true, subtask4 = true;
for(int i = 1; i < n; i++) {
if(c[i] != c[i-1]) subtask3 = false;
}
for(int i = 0; i < q; i++) {
if(v[i] < 0) subtask2 = false;
if(r[i] - l[i] != n-1) subtask4 = false;
}
if(n <= 2000 && q <= 2000) { // Subtask 1
for(int i = 0; i < q; i++) {
for(int j = l[i]; j <= r[i]; j++) {
s[j] += v[i];
s[j] = max(s[j], 0LL);
s[j] = min(s[j], c[j]);
}
}
}
else if(subtask2) {
for(int i = 0; i < q; i++) {
s[l[i]] += v[i];
s[r[i]+1] -= v[i];
}
for(int i = 1; i < n; i++) {
s[i] += s[i-1];
}
for(int i = 0; i < n; i++) {
s[i] = min(s[i], c[i]);
}
}
else if(subtask3) {
}
else if(subtask4) {
}
else {
}
vector<int> sInt(n);
for(int i = 0; i < n; i++) sInt[i] = s[i];
return sInt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
292 KB |
Output is correct |
5 |
Correct |
3 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
15056 KB |
Output is correct |
2 |
Correct |
106 ms |
15056 KB |
Output is correct |
3 |
Correct |
88 ms |
15056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
43 ms |
9684 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
45 ms |
9684 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
292 KB |
Output is correct |
5 |
Correct |
3 ms |
324 KB |
Output is correct |
6 |
Correct |
97 ms |
15056 KB |
Output is correct |
7 |
Correct |
106 ms |
15056 KB |
Output is correct |
8 |
Correct |
88 ms |
15056 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Incorrect |
43 ms |
9684 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |