PARKINGCHARG - Editorial

PROBLEM LINK:

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

Tester and Editorialist: iceknight1093

DIFFICULTY:

416

PREREQUISITES:

None

PROBLEM:

Chef needs to park her car for H hours.
Parking costs Rs. X for the first hour and Rs. Y for each subsequent hour.
How much will Chef pay in parking charges?

EXPLANATION:

The first hour will cost Rs. X.
There are H-1 hours remaining, each costing Rs. Y.

So, the overall cost is

X + (H-1)\cdot Y

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
x, y, h = map(int, input().split())
print(x + y*(h-1))