This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]);
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |