Submission #414030

#TimeUsernameProblemLanguageResultExecution timeMemory
414030TLP39Boxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms204 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; typedef long long int ll; int n,k,l; int cl=0,ch=0; ll dpl[10000001],dph[10000001]; long long delivery(int N, int K, int L, int p[]) { n=N; k=K; l=L; for(int i=0;i<n;i++) { if(p[i]==0) continue; if(p[i]<=l/2) { dpl[cl]=(ll)p[i]; dpl[cl]+=(cl>=k? dpl[cl-k]:0); cl++; } else { dph[ch]=(ll)(l-p[i]); ch++; } } ll temp; for(int i=0;i<ch/2;i++) { temp=dph[i]; dph[i]=dph[ch-1-i]; dph[ch-1-i]=temp; } for(int i=k;i<ch;i++) { dph[i]+=dph[i-k]; } ll ans=2*(dph[ch-1]+dpl[cl-1]); for(int i=0;i<=k;i++) { if(i>cl || k-i>ch) continue; ans=min(ans,(ll)l+2*(dph[ch-1-i]+dpl[cl-1-(k-i)])); } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...