# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
574735 | stevancv | Boxes with souvenirs (IOI15_boxes) | C++14 | 0 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 <bits/stdc++.h>
#include "boxes.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 2e5 + 2;
ll delivery(int N, int K, int D, int pos[]) {
ll n = N;
ll k = K;
ll d = D;
vector<ll> a(n + 2), p(n + 2), s(n + 2);
for (int i = 1; i <= n; i++) {
a[i] = pos[i - 1];
}
a[n + 1] = d;
for (int i = 0; i <= n + 1; i++) {
p[i] = a[i];
s[i] = d - a[i];
}
for (int i = k; i <= n + 1; i++) p[i] += p[i - k];
for (int i = n - k + 1; i >= 0; i--) s[i] += s[i + k];
int l = 0, r = n + 1;
ll ans = 1e18;
while (l < r) {
ll kolko = r - l - 1;
kolko = (kolko + k - 1) / k;
smin(ans, 2 * (p[l] + s[r]) + kolko * d);
ll x = 2 * (p[l + 1] - p[l]);
ll y = 2 * (s[r] - s[r - 1]);
if (x < y) l++;
else r--;
}
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... |