#P1326. CSL Points Range

    ID: 14613 Type: Default 1000ms 256MiB

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 33 points,
  • A draw (when both scores are equal) gives you 11 point,
  • A loss (when your score is strictly less than the opponent's) gives you 00 points.

You are given that you played NN matches in total, scoring SS goals and conceding TT goals overall. In each match, you can decide the result, but the overall totals must be exactly SS and TT. 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 (1,0)(1, 0) (difference +1+1).
  • Draw: assign (0,0)(0, 0) (difference 00).
  • Loss: assign (0,1)(0, 1) (difference 1-1).

Let the number of wins, draws and losses be xx, yy, and zz 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 xx, yy, and zz satisfying the above with

xz=D,x - z = D,

a valid assignment exists if and only if the following conditions can be met:

  1. xSx \le S (since in wins, the minimum goals scored is 11 each),
  2. zTz \le T, (since in losses, the minimum conceded goals is 11 each), and
  3. x+zNx+z \le N (since draws make up the remainder).

We can rewrite z=xDz = x - D. Then the feasibility domain for xx 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 xx. Hence, the minimum total points correspond to the minimum possible valid xx and the maximum total points correspond to the maximum possible valid xx.

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: Pmin=xmin+N+DP_{min} = x_{min} + N + D,
  • Maximum Points: Pmax=xmax+N+DP_{max} = x_{max} + N + D.

Your task is to compute these two values.

inputFormat

The input consists of a single line containing three integers separated by spaces:

  • NN (1N1091 \leq N \leq 10^9): the number of matches,
  • SS (0S1090 \leq S \leq 10^9): the total goals scored,
  • TT (0T1090 \leq T \leq 10^9): the total goals conceded.

It is guaranteed that a valid distribution exists (note that STS-T cannot exceed NN or be less than N-N).

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