Matchmaking Gap

Medium · rating 1350 · Sorting, Greedy

A matchmaker pairs an even number of players to minimise skill mismatches. The first line has n (even). The second line has n ratings. Sort them, pair them up in adjacent order, and print the total rating gap across all pairs.

Constraints: 2 ≤ n ≤ 105, n even

Related problems

Open Matchmaking Gap in Code Arena →