#include "candies.h"
#include <vector>
using namespace std;
int n, q;
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) {
n = c.size();
q = l.size();
vector<int>ans(n,0);
vector<long long>sum(n+1,0);
for(int i=0;i<q;i++){
sum[l[i]]+=v[i];
sum[r[i]+1]-=v[i];
}
for(int i=0;i<n;i++){
if(i>0) sum[i]+=sum[i-1];
ans[i]=min(sum[i],1LL*c[i]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
8988 KB |
Output is correct |
2 |
Correct |
65 ms |
12880 KB |
Output is correct |
3 |
Correct |
72 ms |
12836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |