|
|||
Over Hill and ValleyA tourist hiked through his favorite mountain range, Mátra, over the weekend. Several small settlements were involved in his journey. At the start and every time he arrived at a settlement, he made a note of the number of kilometers he had walked since the last settlement and the population of the settlement he just reached, i.e., the number of people living there. At the end of his tour, he was curious about the total distance he had taken and the difference between the number of inhabitants of the most populated settlement and the least populated settlement on his trip. Write a program that will make the calculations you need for this. The input consists of at least two lines, each with two integers: the distance from the last settlement (in meters) and the number of inhabitants of the settlement reached. Your program must process the lines until end-of-file (EOF). The program should write one line with two integers separated by a space character to the standard output: the length of the trip traveled by the tourist (in meters) and the difference between the number of inhabitants of the most populated settlement and the least populated settlement on his trip. Remember to terminate this line with a newline character. Sample Input
Output for Sample Input
Acknowledgement
This work was supported by the construction EFOP-3.4.3-16-2016-00021. The project was supported by the European Union, co-financed by the European Social Fund.
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |