Submission #364690

#TimeUsernameProblemLanguageResultExecution timeMemory
364690mosiashvililukaBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
568 ms275948 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; long long a,b,c,d,e,i,j,ii,jj,zx,xc,pr[10000009],sf[10000009],pas,f[10000009]; long long delivery(int N, int K, int L, int p[]) { for(i=N; i>=1; i--) f[i]=p[i-1]; for(i=1; i<=N; i++){ if(f[i]<=L-f[i]){ if(i>=K) j=i-K; else j=0; pr[i]=f[i]*2+pr[j]; }else{ if(i>=K) j=i-K; else j=0; pr[i]=L+pr[j]; } //cout<<pr[i]<<" "; } //cout<<endl; // for(i=N; i>=1; i--){ if(f[i]==0) break; if(L-f[i]<=f[i]){ if(i+K>N) j=N+1; else j=i+K; sf[i]=(L-f[i])*2+sf[j]; }else{ if(i+K>N) j=N+1; else j=i+K; sf[i]=L+sf[j]; } } pas=999999999999999999LL; if(f[1]!=0) pas=sf[1]; for(i=1; i<=N; i++){ if(i!=N&&f[i+1]==0) continue; pas=min(pas,pr[i]+sf[i+1]); } return pas; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...