PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: tejas10p
Testers: IceKnight1093, tabr
Editorialist: IceKnight1093
DIFFICULTY:
300
PREREQUISITES:
None
PROBLEM:
Chef bought a stock at value X and sold it at value Y. Did he make a profit, loss, or neither?
EXPLANATION:
This task is solved by simple case analysis:
- If X \gt Y, Chef spent more than he gained, so he made a loss.
- If X \lt Y, Chef spent less than he gained, so he made a profit.
- If X = Y, Chef’s spending equals his gains, so it was a neutral deal.
Check all three cases using if
conditions and print the appropriate answer.
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
x, y = map(int, input().split())
print('Profit' if x < y else 'Loss' if x > y else 'Neutral')