제출 #965096

#제출 시각아이디문제언어결과실행 시간메모리
965096Alihan_8전선 연결 (IOI17_wiring)C++17
7 / 100
144 ms262144 KiB
#include <bits/stdc++.h> #include "wiring.h" using namespace std; #define all(x) x.begin(), x.end() #define ar array #define pb push_back #define ln '\n' //#define int long long using i64 = long long; template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } const i64 inf = 1e18; i64 min_total_length(vector <int> r, vector <int> b){ int n = r.size(), m = b.size(); vector <vector<i64>> dp(n + 1, vector <i64> (m + 1, inf)); dp[0][0] = 0; for ( int i = 1; i <= n; i++ ){ for ( int j = 1; j <= m; j++ ){ int x = abs(r[i - 1] - b[j - 1]); dp[i][j] = min({dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]}) + x; } } 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...