# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1012811 | Luvidi | Boxes with souvenirs (IOI15_boxes) | C++17 | 2056 ms | 29628 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;
#define ll long long
#define pb push_back
long long delivery(int N, int K, int L, int p[]) {
ll n=N,k=K,l=L;
vector<ll> v1,v2;
for(int i=0;i<n;i++){
if(p[i]<=l/2)v1.pb(p[i]);
else v2.pb(l-p[i]);
}
int l1=v1.size(),l2=v2.size();
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
ll dp1[l1+1],dp2[l2+1];
dp1[0]=dp2[0]=0;
for(int i=0;i<l1;i++){
if(i<k)dp1[i+1]=2*v1[i];
else dp1[i+1]=2*v1[i]+dp1[i-k+1];
}
for(int i=0;i<l2;i++){
if(i<k)dp2[i+1]=2*v2[i];
else dp2[i+1]=2*v2[i]+dp2[i-k+1];
}
ll ans=dp1[l1]+dp2[l2];
ans=min(ans,(n+k-1)/k*l);
for(ll x=1;x<=n/k;x++){
for(ll i=1;i<=l1;i++){
if(i+x*k<=l1)continue;
ll j=l2-(i+x*k-l1-2);
if(j<1)continue;
ans=min(ans,x*l+dp1[i-1]+dp2[j-1]);
}
}
return ans;
}
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... |