The Bulgarian city of Nodnol runs a boat service to ferry its residents between the trendy areas in which they live and the large metallic structures in which they work on the next recession.
TFN (Transport For Nodnol) has issued $$$m$$$ travel cards (known affectionally as "Retsyo"), which are numbered from $$$1$$$ to $$$m$$$. Each pier has a card terminal at which passengers are required to tap "in" when starting the trip and to tap "out" when finishing it.
As there is only one card terminal on each pier, passengers use the same device to tap in and to tap out.
Trip cost depends on the distance travelled and is determined as follows:
You are given a sequence of tapping events — for each you have the pier $$$p_i$$$ and card number $$$c_i$$$ recorded. You are to determine how much the transport authority should charge each of the cards
Output $$$m$$$ integers separated by spaces — the $$$i$$$-th integer giving the total charge to be applied to the $$$i$$$-th card.
3 3 5 1 1 1 2 1 2 3 1 2 3
2 100 100
Name |
---|