# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101943 | 2019-03-21T07:07:23 Z | tim25871014 | Wiring (IOI17_wiring) | C++17 | 0 ms | 0 KB |
#include "wiring.h" #include <bits/stdc++.h> using namespace std; long long min_total_length(vector<int> r, vector<int> b){ int n=r.size(),m=b.size(); long long ans=0; if(n>m){ long long minn=2147483647; for(int i=0;i<n;i++) for(int j=0;j<m;j++){ minn=min((long long)abs(b[j]-r[i]),(minn); } ans=ans+minn; } else{ long long minn=2147483647; for(int i=0;i<m;i++) for(int j=0;j<n;j++){ minn=min((long long)abs(b[i]-r[j]),minn); } ans=ans+minn; } return ans; }