Submission #822940

#TimeUsernameProblemLanguageResultExecution timeMemory
822940Minindu206Wiring (IOI17_wiring)C++14
0 / 100
1 ms340 KiB
#include "wiring.h" #include <bits/stdc++.h> #define ll long long using namespace std; long long min_total_length(std::vector<int> r, std::vector<int> b) { int n = r.size(), m = b.size(); if(n <= 200 && m <= 200) { ll ans = 0; vector<int> visb(m, 0); for(int i=0;i<n;i++) { int mn = -1, val = INT_MAX; for(int j=0;j<m;j++) { if(visb[j]) continue; int cur = abs(r[i] - b[j]); if(cur < val) mn = j, val = cur; } visb[mn] = 1; ans += val; } for(int j=0;j<m;j++) { if(visb[j] == 1) continue; int mn = -1, val = INT_MAX; for(int i=0;i<n;i++) { int cur = abs(r[i] - b[j]); if(cur < val) mn = i, val = cur; } ans += val; } return ans; } ll rmx = r[n - 1]; ll ans = 0; for (int i = 0; i < m; i++) ans += b[i] - rmx; for (int i = 0; i < n - 1; i++) ans += rmx - r[i]; ans += max((ll)(n - m) * (b[0] - rmx), 0LL); return ans; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:30:8: warning: variable 'mn' set but not used [-Wunused-but-set-variable]
   30 |    int mn = -1, val = INT_MAX;
      |        ^~
#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...