PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: Utkarsh Gupta
Testers: Utkarsh Gupta, Jatin Garg
Editorialist: Nishank Suresh
DIFFICULTY:
387
PREREQUISITES:
None
PROBLEM:
In a bus with 100 seats, a passenger will always choose to exit from the side closest to their seat. The left exit is beside seat 1 and the right exit is beside seat 100.
Which exit will a passenger at seat X choose?
EXPLANATION
The left exit is closer to seats 1, 2, \ldots, 50, and the right exit is closer to the other seats.
So, the solution is to print “Left” if X \leq 50 and “Right” otherwise.
TIME COMPLEXITY
\mathcal{O}(1) per test case.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
x = int(input())
print('Left' if x <= 50 else 'Right')