Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Prepared By Ibrahim Mesecan.
Toll Plazas
On the highway, the toll plazas have been built. The company have a video survillance.
The company wants a video controlled automatized system to control and compare the results
taken from toll plazas.
There are n cars in a queue and distributed to 3 toll plazas. Every car has three information associated with:
carID, serviceTime, paymentAmount. The cars enter to the left most empty toll plaza. They stay in service
according to serviceTime information and pay the paymentAmount when they leave. After the leave of the current car from
any toll plaza the first car in the queue enters in there.
Question: Write a program that is going to read the car entry information and calculate the sum of payments
for all toll plazas.
Input specification
There is one number (n) at the beginning representing the number of cars in the queue where 1 ≤ n ≤ 1000.
Each of the following n lines contains 3 integers: carID, serviceTime, paymentAmount; where 1 ≤ carID ≤ 10000,
1 ≤ serviceTime (in seconds) ≤ 20, and 1 ≤ paymentAmount ≤ 10.
Output specification
Show three integers which represent the sum of the payment amounts collected by each of the toll plazas.
Sample Input I
5
1 10 5
2 4 4
3 3 5
4 3 6
5 3 7
|
Sample Input II
5
1 5 5
2 3 4
3 4 5
4 3 6
5 3 7
|
Sample Output I
5 11 11
|
Sample Output II
5 10 12
|
Для отправки решений необходимо выполнить вход.
|