제출 #410540

#제출 시각아이디문제언어결과실행 시간메모리
410540dreezy전선 연결 (IOI17_wiring)C++17
0 / 100
1 ms288 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<int,int>
#define pb push_back

const int maxn = 1e5 + 5;

ll min_total_length(vector<int> r, vector<int> b){
	//for each point calculate the closest one
	//pair all the closest ones first
	
	ll ans = 0;
	
	
	
	int n = r.size();
	int m = b.size();
	vector<vector<ll>> dp(n+1, vector<ll>(m+1,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(r[i-1] - b[j-1]);
		}
	}
	
	
	
	return dp[n][m];
}

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:13:5: warning: unused variable 'ans' [-Wunused-variable]
   13 |  ll ans = 0;
      |     ^~~
#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...