# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145388 | Minnakhmetov | Wiring (IOI17_wiring) | C++14 | 42 ms | 6332 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 "wiring.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
const ll INF = 1e18;
const int N = 205;
ll dp[N][N];
ll upd(ll &a, ll b) {
a = min(a, b);
}
ll min_total_length(vector<int> r, vector<int> b) {
int n = r.size(), m = b.size();
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
dp[i][j] = INF;
}
}
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ll val = dp[i][j] + abs(r[i] - b[j]);
upd(dp[i + 1][j], val);
upd(dp[i][j + 1], val);
upd(dp[i + 1][j + 1], val);
}
}
return dp[n][m];
}
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... |