Submission #600401

#TimeUsernameProblemLanguageResultExecution timeMemory
600401Bench0310Boxes with souvenirs (IOI15_boxes)C++17
100 / 100
1480 ms293980 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; const int N=10000000; ll one[N]; ll two[N]; ll delivery(int n,int k,int l,int p[]) { for(int i=0;i<n;i++) if(p[i]==0) p[i]=l; sort(p,p+n); while(n>=1&&p[n-1]==l) n--; if(n==0) return 0; for(int i=0;i<n;i++) one[i]=(i>=k?one[i-k]:0)+2*p[i]; for(int i=n-1;i>=0;i--) two[i]=(i+k<n?two[i+k]:0)+2*(l-p[i]); ll res=min(one[n-1],two[0]); for(int i=0;i+1<n;i++) res=min(res,one[i]+two[i+1]); if(n<=k) res=min(res,ll(l)); for(int i=0;i+k-1<n;i++) res=min(res,l+(i-1>=0?one[i-1]:0)+(i+k<n?two[i+k]:0)); return res; }
#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...