# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
589395 | web | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 212 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 <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include "boxes.h"
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
if(K == 1)
{
long long sum = 0;
long long maxDist = L/2;
for(int i = 0; i<N; ++i)
{
if(p[i] <= maxDist)
{
sum+= p[i];
}
else
{
sum += L - p[i];
}
//cout<<"new sum: "<<sum<<endl;
}
long long maxTravelled = 0;
sum*=2;
/* for(int i = 0; i<N; ++i)
{
if(min(p[i], L-p[i]) > maxTravelled)
maxTravelled = min(p[i], L-p[i]);
}
sum -= maxTravelled;
//cout<<"sum without last "<<sum<<endl;
sum*=2;
sum+=maxTravelled;*/
//cout<<"final sum"<<sum<<endl;
return sum;
}
if(K == N)
{
long long v1 = 0, v2 =0;
for(int i = 0; i<N; ++i)
{
v1 = max(v1, p[i]+0ll);
v2 = max(v2, 0ll +L - p[i]);
}
return min(v1,v2);
}
return 0;
}
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... |