#P16298. [蓝桥杯 2026 省 Python C 组] 解题速度对决

[蓝桥杯 2026 省 Python C 组] 解题速度对决

Problem Description

Under the incandescent lights in the computer lab, the sound of typing rises and falls.

Xiaolan and Xiaohong agree to have a duel on problem-solving speed. There are a total of nn problems in the contest. They start at the same time, and whoever finishes all problems first wins.

Although the problems are the same, their solving rhythms are very different:

  • Xiaolan: Solving each problem always takes t1t_1 minutes. But he has a special habit: after finishing the ii-th problem, he needs to rest for i×d1i \times d_1 minutes to calm down before starting the next problem.
  • Xiaohong: Solving each problem always takes t2t_2 minutes. Similarly, after finishing the ii-th problem, she needs to rest for i×d2i \times d_2 minutes.

You are the judge of this duel. Given the total number of problems and the time parameters of both players, please determine the final winner.

If Xiaolan wins, output BLUE. If Xiaohong wins, output RED. If they finish at the same time, it is a draw; output DRAW.

Input Format

The first line contains an integer TT, indicating that there are TT groups of testdata.

The next TT lines each contain five integers n,t1,d1,t2,d2n, t_1, d_1, t_2, d_2, with meanings as described above.

Output Format

For each group of testdata, output one line with the result:

  • If Xiaolan finishes first, output BLUE.
  • If Xiaohong finishes first, output RED.
  • If they finish at the same time, output DRAW.
3
3 5 2 4 3
3 5 2 4 2
3 5 2 4 4
DRAW
RED
BLUE

Hint

Constraints

For 30%30\% of the test cases, 1≤T≤1001 \le T \le 100, 1≤n,t1,d1,t2,d2≤1031 \le n, t_1, d_1, t_2, d_2 \le 10^3.

For all test cases, 1≤T≤1031 \le T \le 10^3, 1≤n,t1,d1,t2,d2≤1051 \le n, t_1, d_1, t_2, d_2 \le 10^5.

Translated by ChatGPT 5