# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39143 | faustaadp | Boxes with souvenirs (IOI15_boxes) | C++14 | 487 ms | 78668 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 ll long long
using namespace std;
ll n,k,l,i,hs,hz,j,L,R,c1,c2;
unsigned int a[10101010];
ll rct(ll aa,ll bb)
{
if(bb==-1)
return 0;
if(a[aa]*2<=l&&l<=a[bb]*2)
return l;
else
if(a[bb]*2<=l)
return a[bb]*2;
else
return (l-a[aa])*2;
}
ll rmt(ll aa)
{
hz=rct(0,aa);
j=aa;
while(1)
{
if(j+k<n-1)
{
hz+=rct(j+1,j+k);
/*if(a[j+1]*2<=l&&l<=a[j+k])
hz+=l;
else
if(a[j+1]*2<=l)
hz+=a[j+k]*2;
else
hz+=(l-a[j+1])*2;*/
j+=k;
}
else
{
hz+=rct(j+1,n-1);
/*if(a[j+1]*2<=l&&l<=a[n-1])
hz+=l;
else
if(a[j+1]*2<=l)
hz+=a[n-1]*2;
else
hz+=(l-a[j+1])*2;*/
break;
}
}
return hz;
}
long long delivery(int N, int K, int L, int p[]) {
n=N;
k=K;
l=L;
for(i=0;i<n;i++)
a[i]=p[i];
hs=10e17;
//L=-1;
//R=min(k,n);
//while(L<=R)
for(i=-1;i<min(k,n);i++)
{
hs=min(hs,rmt(i));
}
return hs;
}
/*
int main()
{
int n,k,l,i,a[101010];
cin>>n>>k>>l;
for(i=0;i<n;i++)
cin>>a[i];
cout<<delivery(n,k,l,a)<<"\n";
}
*/
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... |