#P7821. Maximum and Minimum Points for Team A in a Football Series
Maximum and Minimum Points for Team A in a Football Series
Maximum and Minimum Points for Team A in a Football Series
In a football tournament, teams from Country A and Country B played (n) matches. The scoring system awards (a) points to the winner, (b) points to the loser, and (c) points to each team in case of a draw. In each match, the goals are allocated so that the winning team scores more than the opponent. It is known that Team A scored a total of (d) goals and Team B scored (e) goals over all matches. Under the constraint that in each match the following holds:
• For a win: the score is at least (1:0) (Team A win) or, if Team B wins, the score is at most (0:1).
• For a draw: the score is (k:k) for some nonnegative integer (k).
A match result is represented by its outcome: win, draw, or loss from the perspective of Team A. Suppose Team A achieves (x) wins, (y) draws and (z) losses (with (x+y+z=n)). Then its tournament points are [ P = a,x + c,y + b,z. ] Moreover, the allocation of goals must be consistent with the outcomes. In particular, note that in a win the minimum allocation is (1:0) (contributing a minimum of (1) goal to Team A and (0) to Team B) and in a loss the minimum is (0:1) (contributing (0) to Team A and (1) to Team B). Extra goals can be added (without changing the outcome) to meet the total goals requirement. However, an important necessary condition comes from the match outcomes. With the minimal scores the total goals would be at least [ \text{Team A}: x, \quad \text{Team B}: z. ] Since extra goals in wins can only increase the margin (and extra goals in draws must be equal for both teams), a necessary feasibility condition is [ x - z \le d - e. ] Also, we must have (x\le d) and (z\le e) (because each win requires at least one goal for Team A and each loss requires at least one goal for Team B) as well as (x+z\le n).
Your task is to determine, over all possible distributions of match outcomes consistent with the totals (d) and (e) and the conditions above, the maximum and minimum possible points that Team A could have achieved.
More formally, let (x,y,z) be nonnegative integers with (x+y+z=n) satisfying [ \begin{cases} x \le d,\ z \le e,\ x - z \le d - e, \end{cases} ] and let the score be [ P = a,x + c,y + b,z. ] Find the maximum and minimum possible values of (P) over all valid ((x,y,z)) assignments.
It is guaranteed that the input parameters allow at least one valid assignment.
inputFormat
The input consists of six integers:
- n: the total number of matches.
- a: points awarded for a win.
- b: points awarded for a loss.
- c: points awarded for a draw.
- d: total goals scored by Team A.
- e: total goals scored by Team B.
All values are separated by spaces.
outputFormat
Output two integers separated by a space: the maximum possible points and the minimum possible points for Team A.
sample
2 3 0 1 2 3
2 0