# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364027 | wind_reaper | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 364 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>
using namespace std;
#define dbg(x) cout << "[" << #x << ": " << x << "] ";
long long delivery(int N, int k, int L, int p[]) {
vector<long long> pref(N+2), suf(N+2), x(N+2);
x[0] = 0;
for(int i = 1; i <= N; i++)
x[i] = (long long)p[i-1];
x[N+1] = 1LL*L;
pref[0] = 0;
for(int i = 1; i <= N + 1; i++)
pref[i] = (i > k ? 2*x[k*(i/k)] + x[i] : x[i]);
suf[N+1] = 0;
for(int i = N; i >= 0; --i)
suf[i] = (N - i + 1 > k ? 2*(L - x[N - k*((N-i+1)/k) + 1]) + L - x[i] : L - x[i]);
long long ans = 1e18;
for(int i = 0; i < N+1; i++)
ans = min(ans, pref[i] + suf[i+1] + L - x[i+1] + x[i]);
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... |