# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
777474 | boris_mihov | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 212 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 <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
typedef long long llong;
const int MAXN = 10000000 + 10;
const llong INF = 1e18;
int n, k, l;
std::vector <int> left;
std::vector <int> right;
llong delivery(int N, int K, int L, int p[])
{
n = N;
k = K;
l = L;
for (int i = 0 ; i < n ; ++i)
{
left.push_back(p[i]);
}
llong ans = INF;
llong curr = 0;
for (int i = 0 ; i < left.size() ; i += k)
{
if (i + k - 1 < left.size())
{
curr += left[i + k - 1] * 2;
} else
{
curr += left.back() * 2;
}
}
ans = curr;
for (int currTry = 0 ; currTry < n ; ++currTry)
{
if (right.size() && right.size() % k != 0)
{
curr -= 2 * right.back();
}
right.push_back(l - left.back());
curr += 2 * right.back();
curr -= 2 * left.back();
left.pop_back();
if (left.size() % k != 0)
{
curr += 2 * left.back();
}
ans = std::min(ans, curr);
}
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... |