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>
using namespace std;
long long int typedef li;
list<int> poz;
long long delivery(int n, int k, int s, int p[])
{
sort(p,p+n);
for (int i=0;i<n;i++) poz.push_back(p[i]);
li ret=0;
while (!poz.empty())
{
if (poz.front()<s-poz.back())
{
int aman=0;
for (int i=0;i<k;i++)
{
aman=poz.front();
poz.pop_front();
if (poz.empty() || aman+s-poz.back()<poz.front()-aman) break;
}
ret+=min(s,2*aman);
}
else
{
int aman=0;
for (int i=0;i<k;i++)
{
aman=s-poz.back();
poz.pop_back();
if (poz.empty() || aman+poz.front()<s-aman-poz.back()) break;
}
ret+=min(s,2*aman);
}
}
return ret;
}
# | 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... |