이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
const int N = 10000007;
int n, k;
int a[N];
ll p[N], s[N];
long long delivery(int N_, int K, int L, int A[])
{
n = N_;
k = K;
for (int i = 1; i <= n; ++i)
a[i] = A[i - 1];
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i)
p[i] = p[max(0, i - k)] + a[i] * 2;
for (int i = n; i >= 1; --i)
s[i] = s[min(n + 1, i + k)] + (L - a[i]) * 2;
ll ans = min(s[1], p[n]);
if (n <= k)
ans = min(ans, (ll)L);
for (int i = 0; i <= n; ++i)
ans = min(ans, p[i] + s[i + 1]);
for (int l = 1; l <= n - k + 1; ++l)
{
int r = l + k - 1;
ans = min(ans, p[l - 1] + s[r + 1] + L);
}
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... |