#P1326. CSL Points Range
CSL Points Range
CSL Points Range
In the Chinese Super League (CSL), the rules for each match are as follows:
- A win (when your score is strictly greater than the opponent's) gives you points,
- A draw (when both scores are equal) gives you point,
- A loss (when your score is strictly less than the opponent's) gives you points.
You are given that you played matches in total, scoring goals and conceding goals overall. In each match, you can decide the result, but the overall totals must be exactly and . Note that for a win, you must score at least one more goal than your opponent, and for a loss, you must score at least one goal less than your opponent. In a draw, the scores are equal. In every match you are free to add extra goals to both teams as long as the relative outcome does not change.
Using a base configuration for each match:
- Win: assign (difference ).
- Draw: assign (difference ).
- Loss: assign (difference ).
Let the number of wins, draws and losses be , , and respectively. Then we have:
$$\begin{array}{l} x+y+z = N,\\ \text{Total points} = 3x + y,\\ \text{And the base difference: }x - z = S - T = D. \end{array}$$Extra goals can be added equally to both teams in a match so as not to change the outcome. This means that given , , and satisfying the above with
a valid assignment exists if and only if the following conditions can be met:
- (since in wins, the minimum goals scored is each),
- , (since in losses, the minimum conceded goals is each), and
- (since draws make up the remainder).
We can rewrite . Then the feasibility domain for is:
$$\max(0, D) \le x \le \min\Big(S, T+D, \;\frac{N+D}{2}\Big). $$Since the total points equal
$$P = 3x + y = 3x + (N - x - z) = 3x + N - x - (x-D) = x + N + D, $$the total points is a linear function of . Hence, the minimum total points correspond to the minimum possible valid and the maximum total points correspond to the maximum possible valid .
Let:
$$x_{min} = \max(0, D) \quad \text{and} \quad x_{max} = \min\Big(S, T+D, \;\left\lfloor\frac{N+D}{2}\right\rfloor\Big). $$Then the minimum and maximum points that can be achieved are:
- Minimum Points: ,
- Maximum Points: .
Your task is to compute these two values.
inputFormat
The input consists of a single line containing three integers separated by spaces:
- (): the number of matches,
- (): the total goals scored,
- (): the total goals conceded.
It is guaranteed that a valid distribution exists (note that cannot exceed or be less than ).
outputFormat
Output two integers separated by a space: the maximum possible total points and the minimum possible total points respectively.
sample
3 4 2
7 7