#include #include #include #include #include using namespace std; struct Judge { Judge(int xc, int yc) { x = xc; y = yc; } int x, y; }; struct Place{ Place(int j, int i, long double d) { id = i; judge = j; distance = d; } long double distance; int judge; int id; bool operator < (const Place & other) { if (distance == other.distance) { if (judge == other.judge) { return id > other.id; } else { return judge > other.judge; } } else { return distance > other.distance; } } }; long double Distance(int a, int b, int c, int d) { long double dx, dy; dx = a-c; dy = b-d; return sqrtl(dx*dx + dy*dy); } long double ProcessItem( vector & judgeList, int count) { int i; vector pits; vector pitUsed(count, false); vector judgeUsed(judgeList.size(),false); int judgesFound = 0; long double totalDistance = 0; // calculate all distances. for(int i=0;i> x >> y; for (int j=0; j 0 and judgesFound < judgeList.size()) { int j = pits.front().judge; int p = pits.front().id; if (!judgeUsed[j] and !pitUsed[p]) { totalDistance += pits.front().distance; judgeUsed[j] = true; pitUsed[p] = true; judgesFound ++; } pop_heap(pits.begin(), pits.end()); pits.pop_back(); } return totalDistance; } int main() { int judges, tars, feathers; long double totalDistance = 0; cin >> judges >> tars >> feathers; for (int i=0;i> x >>y; judgeList.push_back(Judge(x,y)); } totalDistance = ProcessItem(judgeList, tars); totalDistance += ProcessItem(judgeList, feathers); cout << fixed << setprecision(6); cout << totalDistance << endl; return 0; }