HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


170. 50319 - Toll Plazas

Guest
• Review clarifications (1)

Volume problems

• 125. 50538 - Sum of kth Diagonal
• 140. 50599 - Sum of Squared Error ...
• 15-SprPrE1-80. 50741 - DNA Distance
• 151. 50557 - nth Power of m (Long...
• 155. 50334 - What is the class aver...
• 155. 50726 - Pascal Triangle - 1
• 160. 50301 - Fractions to Decimals
• 165. 50360 - National Elections
• 170. 50319 - Toll Plazas
• 180. 50755- Top N Donors - 1
• 185. 50784 - Top Growing Company
• 190. 50734 - Product Info (In Srt)
• 200. 50290 - Minimax Sum
• 210. 50361 - Align Two Lists
• 220. 50754 - Team Standings
• 230. 50286 - Remove Duplicates
• 250. 50448 - Paint Buckets

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