#include "candies.h"
#include <algorithm>
#include <vector>
#include <limits.h>
using namespace std;
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);
for (int j = 0; j < q; ++j) {
int left = l[j];
int right = r[j];
s[left] = (int) min(long(s[left]) + v[j], long(INT_MAX));
if(right < n - 1) {
s[right + 1] = (int) max(long(s[left]) + v[j], long(INT_MIN));
}
}
for(int i = 1; i < n; ++i) {
s[i] = (int) min(long(s[i]) + s[i - 1], long(INT_MAX));
s[i - 1] = min(s[i - 1], c[i - 1]);
}
s[n - 1] = min(s[n - 1], c[n - 1]);
return s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
141 ms |
9640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |