Footrace
Time Limit: 1 sec
The Problem
Two runners, P and M (for Parag and Milton, say), are facing each other in a Footrace. At certain points in time, measurements are taken to ascertain how far each runner has advanced since the most recent measurement. Each time a measurement is taken, a runner’s position corresponds to the sum of that runner’s measurements taken up to that moment.
Develop a program that, given a sequence of such measurements, reports which runner is ahead (if either), and by how much, at the time of each measurement.
The Input
The first line contains a positive integer N (1<N<15) indicating how many times measurements were taken for each runner. On each of the next N lines appears a pair of positive integer measurements, the first of which applies to P (Parag) and the second to M (Milton). The measurement value not more than 10.
The Output
For each pair of measurements, report which runner was ahead, and by how much, when those measurements were taken. The output format is “Measurement X: R ahead by D”, here X is the measurement number start from 1 to N, R is the runner sort name P or M and D is the distance ahead by other runner. If the two runners were even, print “Measurement X: Even”, here X is the measurement number.
Sample Input
4
3 5
2 3
5 2
6 2
Sample Output
Measurement 1: M ahead by 2
Measurement 2: M ahead by 3
Measurement 3: Even
Measurement 4: P ahead by 4
Inter University Programming Contest (Mock) - 2017 [BGC Trust University Bangladesh]
Problem Setter: Shahin ShamS