Football League Tables

Problem #443

Tags: unlabeled

Who solved this?

No translations... yet

In the country of Erehwon the Premier Football League consists of N teams. In the course of a season each team plays each of the other teams twice; once at the home ground and once at the away ground. A team scores 2 points for a win and 1 point for a draw. At the end of the season the League Table (which is in descending order of points) determines the final positions of each team. In the event of a tie at the top of the table a series of playoff games is used to determine the League Champions. These playoff games are not a part of the problem description so may be ignored.

We are interested only in the final League Table and specifically in how many different final League tables could possibly be produced. The actual number is astronomically high so we are going to make some simplifications to reduce the number. The first simplification is to ignore all of the information in the League Table except for the column containing the points for each team. As an example, consider a League with only 3 teams. Even with this small number of teams and the given simplification, we still have 13 possible final League Tables. These are shown below (headed A to M) in the usual column format.

A   B   C   D   E   F   G   H   I   J   K   L   M
8   8   8   7   7   7   6   6   6   6   5   5   4
4   3   2   5   4   3   6   5   4   3   5   4   4
0   1   2   0   1   2   0   1   2   3   2   3   4

As we increase the number of teams the number of possible final League Tables increases rapidly. We further decrease the number of tables by specifying the final points for the bottom two teams in the table. As an example of this, consider a league consisting of just 4 teams. Suppose that the two bottom teams each have 4 points. You should be able to verify that there are 5 different final League Tables which meet this criterion. These are shown below, headed A to E.

A   B   C   D   E
12  11  10  9   8
4   5   6   7   8
4   4   4   4   4
4   4   4   4   4

The examples below are made deliberately small so that you can test your ideas. The actual problem will have a league of 23 teams.

Input/Output description: The first line of the input data will contain a single integer N, the number of teams in the League. The second and final line contains 2 integers; the points totals for the bottom two teams in the League. You need to find the number of different League tables which give rise to these points scores for the bottom two teams.

Example 1:

input:
4
4 4

answer:
5

Example 2:

input:
5
6 4

answer:
17
You need to login to get test data and submit solution.