# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134551 | 20160161simone | Boxes with souvenirs (IOI15_boxes) | C++14 | 2 ms | 504 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 <bits/stdc++.h>
#define M 100000010
using namespace std;
int mi[M];
long long delivery(int N, int K, int L, int p[])
{
if(K==1)
{
long long ans=0;
for(int i=0;i<N;i++) ans+=min(abs(L-p[i]),abs(p[i]))*2;
return ans;
}
if(K==N)
{
int Mli=p[0],Mlx=p[0],Mri=p[N-1],Mrx=p[N-1];
for (int i=0;i<N;i++)
{
if(p[i]*2<L) Mlx=p[i];
if(p[i]*2==L) return L;
if(p[i]*2>L)
{
Mri=p[i];
break;
}
}
if(Mli*2>L)
{
return (L-Mli)*2;
}
else
if(Mrx*2<L)
{
return Mrx*2;
}
else
{
if (L<Mlx*2+(L-Mri)*2) return L;
else return Mlx*2+(L-Mri)*2;
}
}
}
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... |