# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
282279 | tinjyu | Boxes with souvenirs (IOI15_boxes) | C++14 | 558 ms | 294008 KiB |
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 "boxes.h"
#include <iostream>
long long int n,k,l,sum[10000005][2];
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
n=N;
k=K;
l=L;
int mid=n;
for(int i=0;i<n;i++)
{
if(l/2<p[i])
{
mid=i;
break;
}
}
long long tmp=0;
for(int i=0;i<mid;i++)
{
if(i-k>=0)sum[i][0]=sum[i-k][0]+p[i];
else sum[i][0]=p[i];
}
tmp=0;
for(int i=n-1;i>=mid;i--)
{
if(i+k<n)sum[i][1]=sum[i+k][1]+(l-p[i]);
else sum[i][1]=(l-p[i]);
}
long long int ans=sum[mid-1][0]*2+sum[mid][1]*2;
//cout<<sum[mid-1][0]<<" "<<sum[mid][1]<<" "<<ans<<endl;
for(int i=mid-1;i>=mid-k && i>=-1;i--)
{
tmp=0;
if(i>=0)tmp=sum[i][0]*2;
if(i+k+1<n)tmp+=sum[i+k+1][1]*2;
//cout<<i<<" "<<sum[i][0]<<" "<<i+k+1<<" "<<sum[i+k+1][1]<<endl;
tmp+=l;
ans=min(tmp,ans);
}
return ans;
}
Compilation message (stderr)
# | 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... |