#C760. Total Ride Distance Calculation
Total Ride Distance Calculation
Total Ride Distance Calculation
Given a series of rides where each ride's distance is represented in the format km:meters
, compute the total distance covered. The total distance must be expressed in the same format km:meters
where any excess meters (i.e., when the total meters are equal to or exceed 1000) are converted into kilometers.
Formally, if you sum all kilometers (\(km\)) and meters (\(m\)) separately, then convert the total meters \(M\) into kilometers as \(\text{extraKm} = \lfloor M/1000 \rfloor\) and a remainder \(R = M \mod 1000\). The final result would be (total_km + extraKm):R
.
Input/Output Requirement: The input is read from standard input (stdin) and the answer is printed to standard output (stdout).
inputFormat
The first line of input contains a single integer N
representing the number of rides. This is followed by N
lines, each line containing a ride distance in the format km:meters
(for example, 2:350
).
outputFormat
Print a single line containing the total distance in the format km:meters
, after converting every 1000 meters into 1 kilometer.
2
2:350
1:200
3:550
</p>