#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
vector<long long> ans;
vector<int> ret;
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v)
{
int n=c.size(), q=v.size();
for (int i=0; i<n; i++)
{
ans.push_back(0);
ret.push_back(0);
}
for (int i=0; i<q; i++)
{
ans[l[i]]+=v[i];
if (r[i]<=n-2)
ans[r[i]+1]-=v[i];
}
for (int i=1; i<n; i++)
ans[i]+=ans[i-1];
for (int i=0; i<n; i++)
ret[i]=ans[i]=min(c[i]+0LL, ans[i]);
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
9828 KB |
Output is correct |
2 |
Correct |
98 ms |
14012 KB |
Output is correct |
3 |
Correct |
93 ms |
13756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |