# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
826357 | tolbi | Wiring (IOI17_wiring) | C++17 | 18 ms | 1876 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>
using namespace std;
#include "wiring.h"
long long ara(long long a, long long b){
if (a>b) return a-b;
return b-a;
}
long long subtask1(vector<int> &r, vector<int> &b){
int n = r.size();
int m = b.size();
vector<vector<long long>> dp(n, vector<long long>(m,-1));
function<long long(int,int)> f;
f = [&](int x, int y)->long long{
if (dp[x][y]!=-1) return dp[x][y];
if (x==n-1 && y==m-1){
return ara(r[x],b[y]);
}
if (x==n-1){
return dp[x][y]=ara(r[x],b[y])+f(x,y+1);
}
if (y==m-1){
return dp[x][y]=ara(r[x],b[y])+f(x+1,y);
}
dp[x][y]=ara(r[x],b[y]);
long long mava = f(x+1,y+1);
mava=min(mava,f(x,y+1));
mava=min(mava,f(x+1,y));
return dp[x][y]+=mava;
};
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... |