# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305462 | vipghn2003 | Boxes with souvenirs (IOI15_boxes) | C++14 | 1 ms | 384 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<bits/stdc++.h>
using namespace std;
int delivery(int n,int k,int L,int pos[])
{
vector<int>l(n+1),r(n+1);
sort(pos,pos+n);
int mid=L/2+1;
int cntl=0;
for(int i=0;i<n;i++)
{
cntl++;
if(cntl>=k) l[cntl]=l[cntl-k]+pos[i]*2;
else l[cntl]=pos[i]*2;
}
int cntr=0;
for(int i=n-1;i>=0;i--)
{
cntr++;
if(cntr>=k) r[cntr]=r[cntr-k]+(L-pos[i]+1)*2;
else r[cntr]=(L-pos[i]+1)*2;
}
int res=1e9;
for(int i=0;i<=n;i++)
{
res=min(res,l[i]+r[n-i]);
if(n-i-k>=0) res=min(res,l[i]+r[n-i-k]+L);
}
return res;
}
/*
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,k,L;
cin>>n>>k>>L;
int pos[n];
for(int i=0;i<n;i++) cin>>pos[i];
cout<<delivery(n,k,L,pos);
}*/
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... |