You are scheduling a tournament. There are n teams. There are
%7D%7B2%7D)
competitions against every pair of teams. You can schedule a competition each day. For each team, it will arrive in the day when its first competition holds, and leave after its last competition finishes.
For example, there are 3 teams and the schedule is (1,2), (1,3), (2,3). The first team will arrive in day 1, and leave in day 2. It will stay for two days. The second team will stay for three days. The third team will stay for two days.
You want to find a schedule minimizing the sum of days they stay.