[Solution] Miami GP solution codechef

Miami GP solution codechef – Chef has finally got the chance of his lifetime to drive in the F1F1 tournament. But, there is one problem. Chef did not know about the 107% rule and now he is worried whether he will be allowed to race in the main event or not.

[Solution] Miami GP solution codechef

Given the fastest finish time as XX seconds and Chef’s finish time as YY seconds, determine whether Chef will be allowed to race in the main event or not.

Note that, Chef will only be allowed to race if his finish time is within 107% of the fastest finish time.

Input Format

  • First line will contain TT, number of testcases. Then the testcases follow.
  • Each testcase contains of a single line of input, two space separated integers XX and YY denoting the fastest finish time and Chef’s finish time respectively.

Output Format

For each test case, output 𝚈𝙴𝚂YES if Chef will be allowed to race in the main event, else output 𝙽𝙾NO.

You may print each character of the string in uppercase or lowercase (for example, the strings 𝚈𝚎𝚂YeS𝚢𝙴𝚜yEs𝚢𝚎𝚜yes and 𝚈𝙴𝚂YES will all be treated as identical).

[Solution] Miami GP solution codechef

  • 1T21041≤T≤2⋅104
  • 1XY2001≤X≤Y≤200

Sample Input 1 

4
1 2
15 16
15 17
100 107

Sample Output 1 

NO
YES
NO
YES

Miami GP solution Explanation

Test case 11: The fastest car finished in 11 second. Thus, Chef should have finished on or before 1.071.07 seconds to ensure qualification but he finished in 22 seconds. Hence, Chef will not be allowed to race in the main event.

Test case 22: The fastest car finished in 1515 seconds. Thus, Chef should have finished on or before 16.0516.05 seconds to ensure qualification and he managed to finish in 1616 seconds. Hence, Chef will be allowed to race in the main event.

Test case 33: The fastest car finished in 1515 seconds. Thus, Chef should have finished on or before 16.0516.05 seconds to ensure qualification but he finished in 1717 seconds. Hence, Chef will not be allowed to race in the main event.

Test case 44: The fastest car finished in 100100 seconds. Thus, Chef should have finished on or before 107107 seconds to ensure qualification and he finished just in time for qualification. Hence, Chef will be allowed to race in the main event.

For Solution

Click here

Leave a Comment