제출 #491256

#제출 시각아이디문제언어결과실행 시간메모리
491256mosiashvililukaDistributing Candies (IOI21_candies)C++17
3 / 100
5077 ms21792 KiB
#include<bits/stdc++.h> #include "candies.h" using namespace std; const long long N=1000000000000000000LL; long long a,b,c,d,e,i,j,ii,jj,zx,xc,tes,t,C[200009],L[200009],R[200009],V[200009],f[200009],pi,F[200009],mn,mx; pair <long long, long long> p[200009]; vector <int> ans; vector<int> distribute_candies(vector<int> Cc, vector<int> Ll, vector<int> Rr, vector<int> Vv) { a=Cc.size();tes=Ll.size();ans.resize(a); for(i=1; i<=a; i++){ C[i]=Cc[i-1]; } L[1]=1;R[1]=a;V[1]=N; L[2]=1;R[2]=a;V[2]=-N;tes+=2; for(t=3; t<=tes; t++){ L[t]=Ll[t-3]+1;R[t]=Rr[t-3]+1;V[t]=Vv[t-3]; } for(t=1; t<=tes; t++){ pi++;p[pi]={L[t],t};pi++;p[pi]={R[t]+1,-t}; } sort(p+1,p+pi+1); e=1; for(i=1; i<=a; i++){ while(e<=pi&&p[e].first<=i){ ii=p[e].second; if(ii>0){ f[ii]=V[ii]; }else{ f[-ii]=0; } e++; } for(j=1; j<=tes; j++){ F[j]=F[j-1]+f[j]; } mn=N;mx=-N; for(j=tes; j>=1; j--){ mn=min(mn,F[j]);mx=max(mx,F[j]); if(mx-mn>=C[i]){ /*zx=F[tes]-F[j+1]; if(F[j]==mn) ans[i-1]=C[i]+zx; else ans[i-1]=zx;*/ if(F[j]==mn){ ans[i-1]=C[i]+(F[tes]-mx); }else{ ans[i-1]=F[tes]-mn; } break; } } } return ans; }
#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...