Submission #836772

#TimeUsernameProblemLanguageResultExecution timeMemory
836772oscar1fDistributing Candies (IOI21_candies)C++17
0 / 100
85 ms15024 KiB
#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+=typeReq[i]; deb=max(deb,val); } else { val+=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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...