Determine the winner

0

0 votes
Basic Programming, Implementation, Hiring, Basic Programming, Easy, Basics of Implementation, Basics of Implementation
Problem

Assume there are two programmers with their hacker names as Flash and Cisco. They both took part in a contest. The rules of the contest are as follows:

  1. There are four questions to solve P, Q, R, and S.
  2. Initial score (before the start of the contest) of the 4 problems is sp, sq, sr, and ss.
  3. After each minute, the score of the questions, P, Q, R, and S decreases by dp, dq, dr, and ds respectively. The score cannot decrease below half (integer division) of the initial score for each question. In other words, at a specific time, the score of the problems can be the maximum of half of the initial score and the decreased score.

Flash submitted the solutions of the questions at times fp, fq, fr, and fs. Cisco submitted the solutions of the questions at times cp, cq, cr, and cs. Your task is to determine the winner of the contest. The winner is the one who has more score. If the score of both the programmers is the same, then the winner is the one who took less time to solve all the questions. If both the problems have the same score and took the same time to solve the questions, then print Tie.

Note

  • All the times are in minutes.
  • The time taken to solve all the questions is the time at which programmers submit the last solution.

Input format

  • First line: T denoting the number of test cases.
  • For each test case:
    • First line: Four space-separated integers sp, sq, sr, and ss denoting the initial scores of each problem
    • Second line: Four space-separated integers dp, dq, dr, and ds denoting the decrease in each problem's score after each minute
    • Third line: Four space-separated integers fp, fq, fr, and fs denoting the times when Flash submits his solutions
    • Fourth line: Four space-separated integers cp, cq, cr, and cs denoting the times when Cisco submitted his solutions

Output format

Print the winner of the competition, Flash or Cisco. If both the candidates have the same score and took same time to solve the questions, then print Tie.

Constraints

1T105100sp,sq,sr,ss1060dp,dq,dr,ds1060fp,fq,fr,fs1060cp,cq,cr,cs106

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Flash submitted the solutions at time 110, 10, 7 and 8 for the questions P, Q, R and S, respectively. For question P he will get score of only 1000 - 110 * 1 = 890. For question Q he will get 2000 - 10 * 2 = 1980. Similarly, for question R and S, he will get 2790 and 3680. Therefore, the total score is 9340. Total time he took to solve all problems is 110.

Cisco submitted the solutions at time 15, 30, 45 and 55 for the questions P, Q, R and S, respectively. So he will get 985, 1940, 1650 and 3200 score for the questions P, Q, R and S, respectively. Total score is 7775. Total time he took to solve all problems is 45.

Since Flash's total score is greater than Cisco's, Flash is the winner.

Editor Image

?