Kontrola
A train is operating on a line that consists of N stops (including the first and last stops). The train is empty in the beginning and in the end, and for each stop we know the number of passengers that leave the train and the number of passengers that enter the train. Each passenger is traveling for some number of stops and the same passenger never boards the same train more than once. There is a ticket inspector in the train. He walks through the entire train between the first and second stops and inspects the tickets of all passengers currently aboard. After that, the inspector inspects tickets again after every K stops (hence he inspects the ticket between stops a*K+1 and a*K+2 for each integer a). It is therefore possible that some passengers enter and leave the train with their tickets never inspected. Write a program that finds the minimum and maximum possible number of such passengers.
3 2
0 5
4 2
3 0 Output:
2 2Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.