#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
std::vector<int> r, std::vector<int> v) {
int n = c.size(),m=r.size();
if(n<=4000&&m<=4000){
std::vector<int> s(n);
for(int i=0;i<m;i++){
for(int j=l[i];j<=r[i];j++){
s[j]+=v[i];
s[j]=min(c[j],max(0,s[j]));
}
}
return s;
}
vector<int64_t>s(n+1);
for(int i=0;i<m;i++){
s[l[i]]+=v[i];
s[r[i]+1]-=v[i];
}
s.pop_back();
for(int i=1;i<n;i++){
s[i]+=s[i-1];
}
for(int i=0;i<n;i++){
s[i]=min<int64_t>(s[i],c[i]);
}
vector<int>ss(n);
for(int i=0;i<n;i++){
ss[i]=s[i];
}
return ss;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
9048 KB |
Output is correct |
2 |
Correct |
51 ms |
9040 KB |
Output is correct |
3 |
Correct |
52 ms |
9044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
27 ms |
5116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
24 ms |
5008 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
54 ms |
9048 KB |
Output is correct |
7 |
Correct |
51 ms |
9040 KB |
Output is correct |
8 |
Correct |
52 ms |
9044 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Incorrect |
27 ms |
5116 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |