제출 #108602

#제출 시각아이디문제언어결과실행 시간메모리
108602abil전선 연결 (IOI17_wiring)C++14
7 / 100
47 ms7416 KiB
#include <bits/stdc++.h> #include "wiring.h" #define mk make_pair #define sc second #define fr first #define pb push_back #define all(s) s.begin(), s.end() #define sz(s) ( (int)s.size() ) #define Scan(a) scanf ("%I64d", &a) #define scan(a) scanf ("%d", &a) using namespace std; const long long INF = (int)1e18 + 7; const int N = (int)1e5 + 12; const int mod = 1000000007; int dp[222][222] , red[N], blue[N]; long long min_total_length(std::vector<int > r, std::vector<int > b){ int n = r.size(), m = b.size(); memset(dp,0x3f3f3f3f,sizeof(dp)); for(int i = 1;i <= n; i++){ red[i] = r[i - 1]; } for(int i = 1;i <= m; i++){ blue[i] = b[i - 1]; } 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 - 1],dp[i - 1][j],dp[i][j - 1]}) + abs(red[i] - blue[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...