PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: sezalmittal987
Tester: mexomerf
Editorialist: iceknight1093
DIFFICULTY:
TBD
PREREQUISITES:
None
PROBLEM:
In a penalty shootout, team A has scored X points in 3 kicks and team B has Y points in 4 kicks.
Is it possible for scores to be tied after 5 kicks?
EXPLANATION:
Team A can score anywhere between 0 and 2 points from their remaining tries.
So, their final points can be one of \{X, X+1, X+2\}.
Team B can score either 0 or 1 point from their remaining kick, so their final score will be either Y or Y+1.
If there’s any intersection between the sets \{X, X+1, X+2\} and \{Y, Y+1\}, the answer is Yes
- otherwise it’s No
.
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
x, y = map(int, input().split())
if x+2 < y or y+1 < x: print('No')
else: print('Yes')