servers machines numbered from 1 to servers, joined by cables: cables[i] = [u, v] is a cable between servers u and v. The same two servers may be joined by several cables.
The **load** of a pair of servers (a, b) is the number of cables attached to at least one of them. A cable running between a and b themselves is counted once.
For each value thresholds[j], count the pairs a < b whose load is strictly greater than thresholds[j]. Return the answers in the same order.servers=4, cables=[[1, 2], [2, 3], [2, 4], [3, 4]], thresholds=[2, 3] → [6, 2]
Servers 1, 2, 3, 4 have 1, 3, 2 and 2 cables. The pairs (2, 3) and (2, 4) carry 3 + 2 − 1 = 4, the other four pairs carry 3. All 6 pairs exceed 2, and two of them exceed 3.
servers=3, cables=[[1, 2], [2, 1], [1, 2]], thresholds=[0, 2] → [3, 3]
Three parallel cables join 1 and 2: the pair (1, 2) carries 3, and so do (1, 3) and (2, 3), since server 3 has no cables at all. All three pairs exceed 2.
servers=4, cables=[[1, 2], [2, 3], [2, 4], [3, 4]], thresholds=[2, 3]
[6, 2]
Run checks the first 3 tests in your browser. Submit checks all 47 tests on the server, hidden ones included.