# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
619131 | amin | Boxes with souvenirs (IOI15_boxes) | C++14 | 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 "boxes.h"
#include <bits/stdc++.h>
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
long long n=N;
long long k=K;
long long l=L;
sort(p,p+n);
long long preo[n];
long long pree[n];
long long ans[n];
long long v=0;
for(long i=0;i<n;i++)
{
if(i>l/2)
break;
long long sum=0;
for(long y=i;y>=0;y-=k)
{
sum+=p[y];
}
ans[i]=sum*2;
v+=2*p[i];
}
for(long i=n-1;i>=0;i--)
{
if(p[i]<=l/2)
{
break;
}
long long sum=0;
for(long y=i;y<n;y+=k)
{
sum+=(l-p[y]);
}
ans[i]=sum*2;
v+=2*(l-p[i]);
}
return v;
long long h=1e18;
long long f=0;
for(long long i=0;i<=ceil(n/k);i++)
{
long long num=n-i*k;
long long f=i*l;
long long j;
j=1e18;
if(num<=0)
{
h=min(h,f);
break;
}
// cout<<num<<endl;
// cout<<num<<endl;
if(p[n-num]>l/2)
{
j=min(j,f+ans[n-num]);
}
for(long y=0;y<num;y++)
{
// cout<<y<<' '<<i*k+y+1<<endl;
f=i*l;
if(p[y]>l/2)
{
break;
}
if(y+i*k+1==n)
{
j=min(j,f+ans[y]);
break;
}
if(y+i*k+1>n)
{
break;
}
if(p[y+i*k+1]<=l/2)
{
continue;
}
f+=ans[y];
f+=ans[i*k+y+1];
j=min(j,f);
// cout<<y<<' '<<i*k+y+1<<endl;
}
//cout<<j<<endl;
h=min(h,j);
// cout<<j<<endl;
}
return h;
}
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... |