제출 #1068236

#제출 시각아이디문제언어결과실행 시간메모리
1068236Abito전선 연결 (IOI17_wiring)C++17
7 / 100
18 ms5696 KiB
#include "wiring.h" #include <bits/stdc++.h> #define int long long #define pb push_back using namespace std; const int N=505; int n,m,a[N],b[N],dp[N][N]; bool vis[N][N]; int rec(int i,int j){ if (!i && !j) return 0; if (!i || !j) return 1e15; if (vis[i][j]) return dp[i][j]; vis[i][j]=1; return dp[i][j]=min(rec(i-1,j-1),min(rec(i-1,j),rec(i,j-1)))+abs(a[i]-b[j]); } long long min_total_length(std::vector<int32_t> r, std::vector<int32_t> c) { n=r.size(); m=c.size(); for (int i=1;i<=n;i++) a[i]=r[i-1]; for (int i=1;i<=m;i++) b[i]=c[i-1]; return rec(n,m); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...