HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


170. 50319 - Toll Plazas

Guest
• Review clarifications (1)

Volume problems

• 50337 - Exam Averages
• 51149 - One Piece Arena
• 50558 - Biggest Barn
• 50567 - Input Data Normalization
• 50768 - Where is Waldorf?
• 151. 50557 - nth Power of m (Long...
• 160. 50301 - Fractions to Decimals
• 165. 50360 - National Elections
• 170. 50319 - Toll Plazas
• 210. 50361 - Align Two Lists

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
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

Для отправки решений необходимо выполнить вход.

www.contester.ru