# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
416388 | schse | Wiring (IOI17_wiring) | C++17 | 53 ms | 6064 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>
#ifndef EVAL
#include "grader.cpp"
#endif
#define ll long long
#include "wiring.h"
using namespace std;
ll min(ll a, ll b, ll c)
{
return std::min(a, std::min(b, c));
}
long long min_total_length(std::vector<int> r, std::vector<int> b)
{
vector<vector<long long>> dp(2, vector<long long>(b.size() + 1, INT64_MAX));
dp[0][0] = 0;
for (int i = 1; i <= r.size(); i++)
{
for (int e = 0; i + e <= b.size() && e <= 55; e++)
{
dp[(i) % 2][i + e] = min(dp[(i - 1) % 2][i + e - 1],
(e - 0 ? dp[(i - 0) % 2][i + e - 1] : INT64_MAX),
(i - 1 ? dp[(i - 1) % 2][i + e - 0] : INT64_MAX)) +
abs((ll)r[i - 1] - (ll)b[i + e - 1]);
}
}
return dp[r.size() % 2][b.size()];
}
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... |