#define ll long long
#define pll pair<ll, ll>
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v)
{
ll n = c.size();
ll q = l.size();
if(n <= 2000 && q <= 2000)
{
//Subtask 1
vector<ll> a(n, 0);
for(ll i = 0; i < q; i++)
{
for(ll j = l[i]; j <= r[i]; j++)
{
if(v[i] > 0)
{
a[j] = min(a[j]+(ll) v[i], (ll) c[j]);
}
if(v[i] < 0)
{
a[j] = max(a[j]+(ll) v[i], 0LL);
}
}
}
vector<int> output(n, 0);
for(ll i = 0; i < n; i++)
{
output[i] = a[i];
}
return output;
}
return {};
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
216 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
63 ms |
11348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Incorrect |
41 ms |
7984 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
40 ms |
7636 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
216 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
368 KB |
Output is correct |
6 |
Incorrect |
63 ms |
11348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |