# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
786584 | ikaurov | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 340 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"
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define all(arr) (arr).begin(), (arr).end()
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define endl '\n'
const __int128_t INF = 1e25;
long long delivery(int n, int k, int l, int x[]){
vector<ll> pdp(n), sdp(n);
for (int i = 0; i < n; i++){
pdp[i] = (i - k >= 0? pdp[i - k] : 0) + 2 * x[i];
}
for (int i = n - 1; i >= 0; i--){
sdp[i] = (i + k < n? sdp[i + k] : 0) + 2 * (l - x[i]);
}
__int128_t ans = INF;
vector<__int128_t> minval(k, INF);
minval[n % k] = n * 1ll * l;
for (int i = n - 1; i >= -1; i--){
if (minval[(i + 1) % k] != INF){
ans = min(ans, ((__int128_t)k * pdp[i] - l * 1ll * (i + 1) + minval[(i + 1) % k]) / k);
}
ans = min(ans, (__int128_t)(i == -1? 0 : pdp[i]) + (n - i + k - 2) / k * 1ll * l);
if (i == -1) continue;
minval[i % k] = min(minval[i % k], (__int128_t)sdp[i] * k + i * 1ll * l);
}
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... |