# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
725821 | TheSahib | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 308 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
using namespace std;
const ll oo = 1e18;
ll delivery(int N, int K, int M, int p[])
{
vector<int> v;
for (int i = 0; i < N; i++)
{
if(p[i] == 0) continue;
v.push_back(p[i]);
}
N = v.size();
K = min(K, int(v.size()));
if(N == 0) return 0;
ll L[N + 1], R[N + 1];
L[0] = 0;
for (int i = 1; i <= N; i++)
{
L[i] = L[(i - 1) / K * K] + v[i - 1] * 2;
}
R[0] = 0;
for (int i = 1; i <= N; i++)
{
R[i] = R[(i - 1) / K * K] + (M - v[N - i]) * 2;
}
ll ans = oo;
for (int i = 0; i <= N; i++)
{
ans = min(ans, L[i] + R[N - i]);
if(N - i - K >= 0){
ans = min(ans, L[i] + R[N - i - K] + M);
}
}
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... |