Mock CCC '23 2 S3 - Richard The Penguin

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 0.25s
Memory limit: 1G

Problem type

Richard is a penguin running a lockout tournament for N students who are vying to qualify for CCO.

The students are seeded from 1 to N, and every pair of students will face off in a match where either the match ends in a tie or one student wins, and the other loses.

In the event of a tie, both students earn b points. Otherwise, the winner earns a points, and the loser earns c points.

Students are then ranked in decreasing order by their number of points. Students who are tied by points are ranked in increasing order by seed.

For given values of N, K, a, b, and c, compute the maximum and minimum number of points that the student ranked Kth can have.

Constraints

1 \le T \le 10^5

1 \le K \le N \le 10^9

0 \le a, b, c \le 10^9

In tests worth 3 marks, b = 0 and c = 0.

In tests worth an additional 3 marks, b = 0.

In tests worth an additional 3 marks, c = 0.

Input Specification

The first line contains a single integer, T.

The next T lines contain five integers, N, K, a, b, and c.

Output Specification

Output T lines. On the ith line, output two integers, the maximum and minimum number of points the Kth ranked student can have.

Sample Input

1
4 1 3 1 0

Sample Output

9 3

Comments

There are no comments at the moment.