제출 #72932

#제출 시각아이디문제언어결과실행 시간메모리
72932Navick전선 연결 (IOI17_wiring)C++17
0 / 100
3 ms468 KiB
#include <bits/stdc++.h> #include "wiring.h" #define F first #define S second #define pii pair <int, int> #define pb push_back using namespace std; typedef long long ll; const int maxN = 210; const ll oo = 1e16; ll dp[maxN][maxN]; long long min_total_length(std::vector<int> r, std::vector<int> b) { int n = r.size(), m = b.size(); dp[0][0] = 0; for (int j=1; j<=m; j++) dp[0][j] = oo; for (int i=1; i<=n; i++) dp[i][0] = oo; for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) { ll curr = 0; dp[i][j] = oo; for (int k=j-1; k>=0; k--) { curr += abs(r[i - 1] - b[k]); dp[i][j] = min(dp[i][j], curr + dp[i - 1][k]); } } 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...