이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/extc++.h"
using namespace std;
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t;
((cerr << " | " << u), ...);
cerr << endl;
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__)
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
using ll = long long;
#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))
ll delivery(int n, int kv, int m, int arr[]) {
vector<long> dp1(n), dp2(n);
auto g_dp1 = [&](int ind) -> long {
return ind == -1 ? 0 : dp1[ind];
};
auto g_dp2 = [&](int ind) -> long {
return ind == n ? 0 : dp2[ind];
};
for (int i = 0; i < n; i++) {
dp1[i] = 2 * arr[i] + g_dp1(max(-1, i - kv));
}
for (int i = n - 1; i >= 0; i--) {
dp2[i] = 2 * (m - arr[i]) + g_dp2(min(n, i + kv));
}
long ans = 1e18;
auto dp3 = [&](int ind) -> long {
if (ind == n) {
return 0;
}
return m + g_dp2(min(n, ind + kv));
};
for (int i = 0; i <= n; i++) {
ans = min(ans, g_dp1(i - 1) + min(dp3(i), g_dp2(i)));
}
return ans;
}
# | 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... |