Submission #746422

#TimeUsernameProblemLanguageResultExecution timeMemory
746422danikoynov전선 연결 (IOI17_wiring)C++14
7 / 100
23 ms5432 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 210; const ll inf = 1e18; int n, m; ll r[maxn], b[maxn], dp[maxn][maxn]; ll min_total_length(vector<int> R, vector<int> B) { n = R.size(); m = B.size(); for (int i = 1; i <= n; i ++) r[i] = R[i - 1]; for (int i = 1; i <= m; i ++) b[i] = B[i - 1]; r[0] = - inf; b[0] = - inf; for (int i = 0; i <= n; i ++) for (int j = 0; j <= m; j ++) dp[i][j] = inf; dp[0][0] = 0; for (int i = 1; i <= n; i ++) { for (int j = 1; j <= m; j ++) { dp[i][j] = min(dp[i - 1][j], min(dp[i - 1][j - 1], dp[i][j - 1])); dp[i][j] = dp[i][j] + abs(r[i] - b[j]); } } return dp[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...