Submission #414053

#TimeUsernameProblemLanguageResultExecution timeMemory
414053TLP39Boxes with souvenirs (IOI15_boxes)C++14
100 / 100
472 ms119172 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; typedef long long int ll; int n,k,l; int cl=1,ch=1; 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=1;i<(ch+1)/2;i++) { temp=dph[i]; dph[i]=dph[ch-i]; dph[ch-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++) { ans=min(ans,(ll)l+2*(dph[max(ch-1-i,0)]+dpl[max(cl-1-(k-i),0)])); } 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...