# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
990088 | haiphong5g0 | Boxes with souvenirs (IOI15_boxes) | C++14 | 0 ms | 0 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>
#define task "CAU5"
#define pl pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b, c) for (ll i=a; i<=b; i+=c)
#define FORE(i, a, b, c) for (ll i=a; i>=b; i+=c)
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll Mod = 998244353;
const int maxn = 1e7;
const ll Inf = 1e16;
ll delivery(ll n, ll k, ll l, ll A[])
{
ll L[maxn+1], R[maxn+1], ans = Inf;
FOR(i, 1, n, 1) {
ll ans = Inf;
L[i] = (i >= k ? L[i-k] : 0) + A[i-1]*2;
R[i] = (i >= k ? R[i-k] : 0) + (l - A[n-i])*2;
}
FOR(i, 0, n, 1) ans = min(ans, L[i] + R[n-i]);
FOR(i, 0, n-k, 1) ans = min(ans, L[i] + R[n-i-k] + k);
return ans;
}
/*int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(nullptr); cout.tie(nullptr);
int t; ///Setup();
for (t=1; t--;)
{
///Read();
cout << delivery(n, k, l, A);
}
}*/