# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133075 | ckodser | Boxes with souvenirs (IOI15_boxes) | C++14 | 1690 ms | 412164 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
#define F first
#define S Second
#define pb push_back
#define pii pair<ll,ll>
#define mp make_pair
using namespace :: std;
const ll maxn=3e7+500;
const ll inf=1e17+900;
ll sagh(ll n,ll k){return (n/k)+(n%k!=0);}
ll dp[maxn];
long long delivery(int n, int k, int L, int p[]) {
fill(dp,dp+maxn,inf);
k=min(k,n);
ll u=n%k;
for(ll i=0;i<k;i++){
vector<ll> l,r,vec;l.reserve(n/k+2);r.reserve(n/k+2);
for(ll j=i+k-1;j<n;j+=k){
l.pb(p[j]);
}
ll ii=(u-i+k)%k;
ll cnt=1;
for(ll j=n-ii-k;j>=0;j-=k){
r.pb(L-p[j]);
}
ll ct=0;
if(i)ct+=p[i-1];
if(ii)ct+=(L-p[n-ii]);
for(auto v:l)vec.pb(v);
for(auto v:r)vec.pb(v);
sort(vec.begin(),vec.end());
ll pr=ct;
for(ll j=0;j<vec.size();j++){
dp[j*k+i+ii]=min(dp[j*k+i+ii],pr);
pr+=vec[j];
}
dp[vec.size()*k+i+ii]=min(dp[vec.size()*k+i+ii],pr);
}
ll ans=sagh(n,k)*L;
for(ll i=0;i*k<=n;i++){
ans=min(ans,dp[n-i*k]*2+L*i);
}
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... |