#include "candies.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define add push_back
#define pii pair<int, int>
#define len(a) ((int)(a).size())
#define all(a) a.begin(), a.end()
#define fr first
#define sc second
const int N = 3e5 + 5;
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
vector<int> ret;
if(len(c) <= 2000 && len(l) <= 2000){
int now = 0;
for(int i = 0; i < len(c); i++){
now = 0;
for(int j = 0; j < len(l); j++){
if(l[j] <= i && i <= r[j]) {
if(v[j] < 0) now = max(0, now + v[j]);
else now = min(c[i], now + v[j]);
}
}
ret.add(now);
}
return ret;
}
vector<int> dif;
dif.resize(len(c) + 5, 0);
for(int i = 0; i < len(l); i++){
dif[l[i]] += v[i];
dif[r[i] + 1] -= v[i];
}
int now = 0;
for(int i = 0; i < len(c); i++){
now += dif[i];
ret.add(min(now, c[i]));
}
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
13 ms |
412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
96 ms |
8416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
47 ms |
7964 KB |
Output isn't correct |
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 |
Incorrect |
58 ms |
7624 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
13 ms |
412 KB |
Output is correct |
6 |
Incorrect |
96 ms |
8416 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |