제출 #420102

#제출 시각아이디문제언어결과실행 시간메모리
420102Maqsut_03전선 연결 (IOI17_wiring)C++14
0 / 100
1 ms308 KiB
#include "wiring.h" #include<bits/stdc++.h> using namespace std; #define N 200100 int n, m, a[N]; long long ans = 0; long long min_total_length(vector<int> r, vector<int> b) { n = r.size(); m = b.size(); for (int i=0; i<n; i++) { long long mn = 1e18; int k = 0; for (int j=0; j<m; j++) { if (abs(r[i] - b[j]) <= mn) mn = abs(r[i] - b[j]), k = j; } a[k]++; ans += mn; } for (int i=0; i<m; i++) { if (a[i] == 0) { long long mn = 1e18; for (int j=0; j<n; j++) mn = min(mn, 1ll*abs(b[i] - r[j])); for (int j=0; j<m; j++) mn = min(mn, 1ll*abs(b[i] - b[j])); ans += mn; } } return ans; }
#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...