# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101936 | 2019-03-21T06:59:47 Z | tim25871014 | Wiring (IOI17_wiring) | C++17 | 0 ms | 0 KB |
#include "wiring.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){ int minn=2147483647; for(int i=0;i<n;i++) for(int j=0;j<m;j++){ minn=min(abs(b[j]-r[i]),minn); } ans=ans+minn; } else{ int minn=2147483647; for(int i=0;i<m;i++) for(int j=0;j<n;j++){ minn=min(abs(b[i]-r[j]),minn); } ans=ans+minn; } return ans; }