Google Big Code
You are managing a distributed datacenter network with N server nodes connected by M bidirectional fiber-optic links. The network may consist of multiple connected components, nodes within the same component can communicate with each other, while nodes in different components cannot.
Each node i has a computational capacity value. You must assign the N available capacity values to the N nodes, each node receives exactly one value and each value is used exactly once, to maximize the total network efficiency.
For each node i, define:
The score of node i is:
If the graph has no edges (M = 0), every node forms its own component of size 1 with degree 0, giving every node a score of 1.
Find an assignment of capacity values to nodes that maximizes:
Complete the solve function. It receives N, M, A, and edges, and returns the maximum possible total efficiency as a long long integer.
Explanation The Optimal Assignment: To get the highest possible efficiency, we multiply the highest scores (7, 7, 7) by the largest available capacities (50, 40, 30), and the lower scores (6, 6) by the remaining capacities (20, 10). Adding those products gives the final answer of 1020.