# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68246 | mirbek01 | Wiring (IOI17_wiring) | C++17 | 58 ms | 10020 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;
long long dp[202][202];
long long min_total_length(vector<int> r, vector<int> b) {
long long ans = 0;
int n = (int)(r.size());
int m = (int)(b.size());
if(n <= 200 && m <= 200){
for(int i = 0; i < n; i ++){
for(int j = 0; j < m; j ++){
long long res = abs(r[i] - b[j]), mn = 1e18;
if(i)
mn = dp[i - 1][j];
if(j)
mn = min(mn, dp[i][j - 1]);
if(i && j)
mn = min(mn, dp[i - 1][j - 1]);
if(mn == 1e18)
dp[i][j] = res;
else
dp[i][j] = res + mn;
}
}
return dp[n - 1][m - 1];
}
for(int i = 0; i < n; i ++)
# | 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... |