CASHBACK - Editorial

PROBLEM LINK:

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

Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

A customer buys a cake for X rupees.
If the cost is at least 200 rupees, a cashback of 50 is given.
What’s the effective cost to the customer?

EXPLANATION:

If X \lt 200, there’s no cashback and so the effective price is just X.

If X \ge 200, there’s a cashback of 50 rupees, so the effective price is (X - 50) instead.

Both cases can be checked using an if statement.

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
x = int(input())
if x < 200: print(x)
else: print(x - 50)