# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74711 | doowey | Boxes with souvenirs (IOI15_boxes) | C++14 | 543 ms | 170968 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;
typedef long long ll;
vector<ll> bef, aft;
ll delivery(int N, int K, int L, int p[]) {
for(int i = 0; i < N; i ++ ){
if(p[i] <= L/2)
bef.push_back(p[i] * 2);
else
aft.push_back((L-p[i])*2);
}
reverse(aft.begin(), aft.end());
for(int i = K; i < bef.size(); i ++ )
bef[i] += bef[i-K];
for(int i = K; i < aft.size(); i ++ )
aft[i] += aft[i - K];
int tr;
ll ans = (ll)1e18;
ll sum;
for(int tl = 1; tl <= K; tl ++ ){
tr = K-tl;
sum = L;
if(tl < (int)bef.size())
sum += bef[bef.size()-tl-1];
if(tr < (int)aft.size())
sum += aft[aft.size()-tr-1];
ans = min(ans, sum);
}
sum = 0;
if(!bef.empty())
sum += bef.back();
if(!aft.empty())
sum += aft.back();
ans = min(ans, sum);
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... |