# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
771301 | caganyanmaz | 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 <bits/stdc++.h>
#define pb push_back
#define DEBUGGING
#define f first
#define s second
#define int int64_t
#ifdef DEBUGGING
#define debug(x) cout << (#x) << ": " << (x) << "\n";
#else
#define debug(x) 42
#endif
using namespace std;
constexpr static int MXSIZE = 1e7 + 2;
int left_dp[MXSIZE];
int right_dp[MXSIZE];
vector<int> left_val;
vector<int> right_val;
int mid = 0;
int delivery(int32_t N, int32_t K, int32_t L, int32_t p[])
{
for (int i = 0; i < N; i++)
if (p[i] < (L / 2))
left_val.pb(p[i]);
else if (p[i] > (L / 2))
right_val.pb(p[i]);
else
mid++;
for (int i = 1; i <= left_val.size(); i++)
{
if (i - K >= 0)
left_dp[i] = left_dp[i-K];
left_dp[i] += left_val[i-1] * 2;
}
for (int i = 1; i <= right_val.size(); i++)
{
if (i - K >= 0)
right_dp[i] = right_dp[i-K];
right_dp[i] += (L - right_val[right_val.size()-i]) * 2;
}
int res = left_dp[left_val.size()] + right_dp[right_val.size()] + (mid/K) * L;
if (mid%K)
res += L;
for (int j = 1; j <= 4; j++)
{
int lo = K * j - (mid % K);
for (int i = 0; i <= lo; i++)
res = min(res, left_dp[left_val.size()-i] + right_dp[right_val.size()-lo+i] + ((mid+lo)/K) * L);
}
return res;
}
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... |