#include<bits/stdc++.h>
#include "candies.h"
using namespace std;
using ll=long long;
const int TAILLE_MAX=200*1000+5;
int nbVal,nbReq;
vector<int> capa,debReq,finReq,typeReq;
vector<int> rep;
vector<int> distribute_candies(vector<int> c,vector<int> l,vector<int> r,vector<int> v) {
capa=c;
debReq=l;
finReq=r;
typeReq=v;
nbVal=capa.size();
nbReq=typeReq.size();
rep.resize(nbVal);
/*ll val=0,deb=0;
for (int i=0;i<nbReq;i++) {
if (typeReq[i]>0) {
val+=(ll)typeReq[i];
deb=max(deb,val);
}
else {
val+=(ll)typeReq[i];
if (val<=0) {
val=0;
deb=0;
}
}
}
for (int j=0;j<nbVal;j++) {
if (capa[j]>=deb) {
rep[j]=val;
}
else {
rep[j]=max(val-(deb-capa[j]),(ll)0);
}
//cout<<rep[j]<<" ";
}
//cout<<endl;*/
for (int ireq=0;ireq<nbReq;ireq++) {
for (int i=debReq[ireq];i<=finReq[ireq];i++) {
if (typeReq[ireq]>0) {
rep[i]=min(capa[i],rep[i]+typeReq[ireq]);
}
else {
rep[i]=max(0,rep[i]+typeReq[ireq]);
}
}
/*for (int i:rep) {
cout<<i<<" ";
}
cout<<endl;*/
}
return rep;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 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 |
2 ms |
372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5061 ms |
10468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
146 ms |
10396 KB |
Output is correct |
3 |
Correct |
144 ms |
7596 KB |
Output is correct |
4 |
Execution timed out |
5057 ms |
14256 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
356 ms |
9932 KB |
Output is correct |
4 |
Correct |
358 ms |
5584 KB |
Output is correct |
5 |
Execution timed out |
5085 ms |
13904 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 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 |
2 ms |
372 KB |
Output is correct |
6 |
Execution timed out |
5061 ms |
10468 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |