#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int n, q;
int arr[N], capacity[N];
vector<int> distribute_candies(vector<int> c, vector<int> l,
vector<int> r, vector<int> v) {
n = c.size(), q = l.size();
if(n > 2000) return {};
for(int i=1 ; i<=n ; i++) capacity[i] = c[i-1];
for(int i=0 ; i<q ; i++)
{
int a = l[i]+1, b = r[i]+1, c = v[i];
for(int j=a ; j<=b ; j++)
{
arr[j] += c;
arr[j] = max(arr[j], 0);
arr[j] = min(arr[j], capacity[j]);
}
}
vector<int> ret;
for(int i=1 ; i<=n ; i++) ret.push_back(arr[i]);
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
96 ms |
6460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
233 ms |
5040 KB |
Output is correct |
3 |
Incorrect |
29 ms |
1848 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 |
204 KB |
Output is correct |
3 |
Correct |
492 ms |
5048 KB |
Output is correct |
4 |
Incorrect |
27 ms |
1860 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Incorrect |
96 ms |
6460 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |