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<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dp1[10000005], dp2[10000005];
ll delivery(int N, int K, int L, int *positions)
{
for(int i=N ; i>0 ; i--) positions[i]=positions[i-1];
for(int i=1 ; i<=N ; i++)
{
if(i<K) dp1[i]=positions[i]+min(positions[i],L-positions[i]);
else dp1[i]=dp1[i-K]+positions[i]+min(positions[i],L-positions[i]);
}
for(int i=N ; i>=1 ; i--)
{
if(N-i<K) dp2[i]=(L-positions[i])+min(positions[i],L-positions[i]);
else dp2[i]=dp2[i+K]+(L-positions[i])+min(positions[i],L-positions[i]);
}
ll res=dp1[0]+dp2[1];
for(int i=1 ; i<=N ; i++) res=min(res,dp1[i]+dp2[i+1]);
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... |