#C7842. Parking Fee Calculation
Parking Fee Calculation
Parking Fee Calculation
You are given the start and end times of a parking session in the format (HH:MM) along with two different rates: one for the first hour and one for every additional hour. If the parking duration includes any partial hour after the first hour, it should be rounded up to the next whole hour. The fee is calculated as follows:
[ \text{total_hours} = \lceil \frac{\text{duration in minutes}}{60} \rceil ]
If (total_hours \leq 1), then the fee is equal to the first hour rate. Otherwise, the fee is computed as:
[ \text{fee} = \text{first_hour_rate} + (\text{total_hours} - 1) \times \text{additional_hour_rate} ]
Write a program that reads the input from standard input and prints the calculated parking fee to standard output.
inputFormat
The input consists of a single line containing four values separated by spaces:
- The start time in the format HH:MM.
- The end time in the format HH:MM (guaranteed to be later than the start time).
- An integer representing the rate for the first hour.
- An integer representing the rate for each additional hour.
outputFormat
Output a single integer representing the total parking fee calculated according to the given rules.## sample
10:00 11:00 5 3
5