F1RULE - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: Tejas Pandey
Testers: Satyam, Abhinav Sharma
Editorialist: Nishank Suresh

DIFFICULTY:

To be calculated

PREREQUISITES:

None

PROBLEM:

Chef participates in a qualifying F1 race. The fastest finish time is X seconds, and Chef’s finish time is Y seconds.

According to the 107% rule, Chef will qualify to the main event if his time is at most 107% of the fastest time. Will Chef qualify?

EXPLANATION:

This is a simple implementation problem which only requires the checking of one condition — whether Y is at most 107% of X.

The easiest way to do this is to calculate 107% of X and check whether Y exceeds it, i.e, check if Y \leq 1.07 \cdot X.

The safest way to implement this, however, is to multiply both sides of the above equation by 100 and check if 100 Y \leq 107 X — this avoids any annoying errors which may pop up by comparing floating-point numbers (in this problem, X and Y are small enough that float and double may be safely used, but it isn’t always the case, and writing safe code is a good practice).

TIME COMPLEXITY:

\mathcal{O}(1) per test.

CODE:

Python
for _ in range(int(input())):
	x, y = map(int, input().split())
	if 100*y <= 107*x:
		print('YES')
	else:
		print('NO')