#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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
81 ms |
11340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |