제출 #389181

#제출 시각아이디문제언어결과실행 시간메모리
389181MilosMilutinovic전선 연결 (IOI17_wiring)C++14
20 / 100
33 ms3780 KiB
#include <bits/stdc++.h> #include "wiring.h" using namespace std; long long min_total_length(vector<int> a, vector<int> b) { int n = (int) a.size(), m = (int) b.size(); if (n <= 200 && m <= 200) { const long long inf = 1e17; vector<vector<long long>> dp(n + 1, vector<long long>(m + 1, 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], dp[i][j - 1], dp[i - 1][j - 1]}) + abs(a[i - 1] - b[j - 1]); } } return dp[n][m]; } if (a[n - 1] < b[0]) { long long ans = 0; for (int i = 0; i < n; i++) ans += (a[n - 1] - a[i]); for (int i = 0; i < m; i++) ans += (b[i] - b[0]); ans += (long long) (b[0] - a[n - 1]) * max(n, m); return ans; } }

컴파일 시 표준 에러 (stderr) 메시지

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^
#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...