# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1058983 | andrei_iorgulescu | 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;
using ll = long long;
ll inf = (ll)1e9 * (ll)1e9;
ll delivery(int N, int k, int L, int positions[])
{
vector<int> p(N + 1);
for (int i = 1; i <= N; i++)
p[i] = positions[i - 1];
ll ans = inf;
vector<int> revp(N + 1);
for (int i = 1; i <= N; i++)
revp[i] = (L - p[i]);
ll s1 = 0, s2 = 0;
for (int i = 1; i < N; i++)
{
if ((N + 1 - i) % k == 0)
s2 += min(L, 2 * revp[i]);
}
for (int m = 0; m <= N; m++)
{
///Mk de la 1 la m - 1
if (m - 1 >= 0 and (m - 1) % k == 0)
s1 += min(L, 2 * p[m - 1]);
///N + 1 - Mk de la m + 2 la N
if ((N - m) % k == 0 and m + 1 <= N)
s2 -= min(L, 2 * revp[m + 1]);
ll s1 = 0, s2 = 0;
for (int i = k; i < m; i += k)
s1 += min(2 * p[i], L);
for (int i = N - k + 1; i > m + 1; i -= k)
s2 += min(2 * revp[i], L);
ll kk = s1 + s2;
if (m != 0)
kk += min(L, 2 * p[m]);
if (m != N)
kk += min(L, 2 * revp[m + 1]);
ans = min(ans,kk);
}
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... |