PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: Jeevan Jyot Singh
Testers: Utkarsh Gupta, Hriday
Editorialist: Nishank Suresh
DIFFICULTY:
451
PREREQUISITES:
None
PROBLEM:
Uttu broke his phone. He can get it fixed for X rupees or buy a new one for Y rupees. Which option is cheaper?
EXPLANATION:
There are three cases:
- If X \lt Y, print “Repair”
- If X \gt Y, print “New phone”
- If X = Y, print “Any”
The three cases can be checked using if
conditions.
TIME COMPLEXITY
\mathcal{O}(1) per test case.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
x, y = map(int, input().split())
print('repair' if x < y else ('new phone' if x > y else 'any'))