Submission #1051312

#TimeUsernameProblemLanguageResultExecution timeMemory
1051312pawnedWiring (IOI17_wiring)C++17
7 / 100
97 ms262144 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back typedef long long ll; typedef pair<ll, ll> ii; typedef vector<ll> vi; #include "wiring.h" ll min_total_length(vector<int> r_g, vector<int> b_g) { vi r, b; for (int x : r_g) r.pb(x); for (int x : b_g) b.pb(x); int N = r.size(); int M = b.size(); vector<vi> dp(N + 1, vi(M + 1, 1e18)); // dp[i][j]: min cost to connect first i red (exclusive) // with first j blue (exclusive) dp[0][0] = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { dp[i][j] = min(min(dp[i][j - 1], dp[i - 1][j]), dp[i - 1][j - 1]) + abs(r[i - 1] - b[j - 1]); } } 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...