P7821 "RdOI R3" race
Description
In a football tournament, Team A and Team B played a total of $n$ matches. The tournament uses a point system: the winning team gets $a$ points, the losing team gets $b$ points, and if the match is a draw then both teams get $c$ points each. It is known that Team A scored a total of $d$ goals, and Team B scored a total of $e$ goals. Find the maximum possible total score and the minimum possible total score for Team A.
Input Format
**This problem contains multiple test cases.**
The first line contains an integer $T$, the number of test cases.
For each test case, input one line with six integers $n,a,b,c,d,e$.
Output Format
For each test case, output one line with two integers separated by a space, representing the maximum possible total score and the minimum possible total score.
Explanation/Hint
### Sample Explanation
To make the samples easier to understand, the sample explanations for the first three test cases are given below:
| Test Case | Maximum Score Plan | Minimum Score Plan |
| --------- | -------------------------------- | -------------------------------- |
| $1$ | $(1,0),(0,0),(2,1),(0,0),(2,1)$ | $(0,0),(5,0),(0,1),(0,0),(0,1)$ |
| $2$ | $(0,0),(0,5),(0,0),(0,0),(0,0)$ | $(0,1),(0,1),(0,1),(0,1),(0,1)$ |
| $3$ | $(3,2),(0,2),(3,2)$ | $(6,6),(0,0),(0,0)$ |
In the table, $(x_1,y_1),(x_2,y_2),\cdots,(x_n,y_n)$ means the score of match $1$ is $x_1:y_1$, the score of match $2$ is $x_2:y_2$, and so on.
---
### Constraints
**This problem uses bundled testdata.**
For all test cases, $1\le T\le 10^5$, $1\le n \le 10^9$, $0\le d,e\le10^9$, $0\le b\le c \le a\le10^9$.
| subtask | Score | Special Constraint | Dependencies |
| ------- | ----- | --------------------- | ------------ |
| $1$ | $10$ | $e=0$ | None |
| $2$ | $20$ | $n,d,e\le 5,T\le100$ | None |
| $3$ | $20$ | $n\le 5$ | $2$ |
| $4$ | $50$ | None | $1,3$ |
Translated by ChatGPT 5