# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1040038 | Kipras | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 440 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>
typedef long long ll;
using namespace std;
ll delivery(int n, int k, int l, int pos[]){
ll mid = (l+1)/2;
vector<ll> dp1, dp2;
dp1.push_back(0);
dp2.push_back(0);
for(int i = 0; i < n && pos[i]<=mid; i++){
if(i==0){
dp1.push_back(pos[i]*2);
continue;
}
if(i%k!=0)dp1.push_back(dp1.back()+pos[i]*2-pos[i-1]);
else dp1.push_back(dp1.back()+pos[i]+pos[i-1]);
}
for(int x = n-1; x >= 0 && pos[x]>=mid; x--){
if(x==n-1){
dp2.push_back(pos[x]*2);
continue;
}
ll ind = x-n+1;
if(ind%k!=0)dp2.push_back(dp2.back()+pos[x]*2-pos[x+1]);
else dp2.push_back(dp2.back()+pos[x]+pos[x+1]);;
}
/*cout<<dp1.size()<<" 1, "<<dp2.size()<<" 2: \n";
for(auto i : dp1)cout<<i<<" ";
cout<<"\n";
for(auto i : dp2)cout<<i<<" ";
cout<<"\n";*/
ll rez = 1e18;
for(int i = 0; i < dp1.size(); i++){
if(dp2.size()>n-i)rez=min(rez, dp1[i] + dp2[n-i]);
if(dp2.size()>n-i-k&&n-i-k>=0)rez=min(rez, dp1[i] + dp2[n-i-k] + l);
}
return rez;
}
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... |