Submission #296908

#TimeUsernameProblemLanguageResultExecution timeMemory
296908ASDF123Wiring (IOI17_wiring)C++17
0 / 100
4 ms4992 KiB
#include "wiring.h" //#include "grader.cpp" #include <bits/stdc++.h> #define szof(s) (int)s.size() #define pii pair<int, int> #define ll long long #define fr first #define sc second using namespace std; const int N = (int)2e5 + 5; vector <int> g[N]; bool used[N]; struct Edge { int u, v, len; Edge(int u_, int v_, int len_) { u = u_, v = v_, len = len_; } Edge () { } }; bool operator < (const Edge &a, const Edge &b) { return a.len < b.len; } long long min_total_length(vector<int> r, vector<int> b) { vector <Edge> edges; for (int i = 0; i < szof(r); i++) { for (int j = 0; j < szof(b); j++) { int u = i + 1; int v = szof(r) + j + 1; edges.push_back(Edge(u, v, abs(r[i] - b[j]))); } } sort(edges.begin(), edges.end()); ll ans = 0; for (Edge el : edges) { if (!used[el.u] || !used[el.v]) { used[el.u] = used[el.v] = 1; ans += el.len; } } 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...