TOURPLAN - Editorial

PROBLEM LINK:

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

Author: iceknight1093
Tester: raysh07
Editorialist: iceknight1093

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

A cab costs X rupees for the first 50 kilometers, and Y rupees per kilometer after that.
You need to travel for Z kilometers. How much will you pay?

EXPLANATION:

If Z \le 50, then you only need to pay the base cost of X rupees since that covers 50 kilometers.
So, the answer in this case is X.

If Z \gt 50, there are then (Z - 50) extra kilometers added on to the base cost.
Each extra kilometer costs Y. So, the extra cost is Y\times (Z - 50).
So, in this case the answer is

X + Y\cdot (Z - 50)

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
x, y, z = map(int, input().split())
if z <= 50: print(x)
else: print(x + (z - 50) * y)