# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061215 | codefox | Boxes with souvenirs (IOI15_boxes) | C++14 | 1 ms | 348 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>
#include "boxes.h"
using namespace std;
#define ll long long
ll delivery(int N,int K,int L,int positions[])
{
deque<ll> first;
deque<ll> second;
for (int i = 0;i < N; i++)
{
if (positions[i]==0) continue;
if (positions[i]<=L/2) first.push_back(positions[i]);
else second.push_front(positions[i]);
}
ll m = 1e18;
vector<ll> best1(first.size());
vector<ll> best2(second.size());
for (int i = 0; i < first.size(); i++)
{
if (i >= K) best1[i] = best1[i-K]+ first[i]*2;
else best1[i] = first[i]*2;
}
for (int i = 0; i < second.size(); i++)
{
if (i>= K) best2[i] = best2[i-K]+ (L-second[i])*2;
else best2[i] =(L-second[i])*2;
}
ll sol = best1.back()+best2.back();
ll mn = 1e18;
for (int i = 1; i < min((int)best1.size(), K); i++)
{
if (K-i >= best2.size()) continue;
mn = min(mn, best1[best1.size()-i]+best2[best2.size()-K+i]+L);
}
return min(mn, sol);
}
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... |