제출 #145388

#제출 시각아이디문제언어결과실행 시간메모리
145388MinnakhmetovWiring (IOI17_wiring)C++14
7 / 100
42 ms6332 KiB
#include "wiring.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const ll INF = 1e18;
const int N = 205;
ll dp[N][N];

ll upd(ll &a, ll b) {
	a = min(a, b);
}

ll min_total_length(vector<int> r, vector<int> b) {
	int n = r.size(), m = b.size();

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dp[i][j] = INF;
		}
	}

	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			ll val = dp[i][j] + abs(r[i] - b[j]);
			upd(dp[i + 1][j], val);
			upd(dp[i][j + 1], val);
			upd(dp[i + 1][j + 1], val);
		}
	}

	return dp[n][m];
}

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

wiring.cpp: In function 'long long int upd(long long int&, long long int)':
wiring.cpp:15:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#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...