HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data Structures: Arrays > problem:


50420 - Teachers Sightseeing

Guest
• Review clarifications (1)

Section problems

• 50410 - Zero Padding
• 50329 - Draw Matrix-1
• 50337 - Exam Averages
• 50334 - What is the class average?
• 50383 - Noisy Mornings
• 51129 - Hexagon
• 51097 - Sum of Borders
• 50419 - The longest bitonic sequence
• 50420 - Teachers Sightseeing
• 50344 - Profit or Loss
• 50431 - Sultan's Game
• 50445 - Cryptography
• 51246 - Swap largest word, reverse ...
• 50516 - Lines
• 50446 - Snake
• 50345 - Orders
• 50822 - Linked List

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.
Question by Halil Karimis.

Teachers Sightseeing Tour in Konya

Question: A group of teachers go to Konya for sightseeing. After visiting for a while, they go to a restaurant for lunch. There are different types of foods there. Everyone has ordered different food with different prices. After the meal, everyone paid the money and then they left the restaurant. Group leader wants to know the total amount paid to the restaurant, and the list of all teachers from the most payers to the least payers. Write a program to make the teacher's job easier.

Input specification
On the first line types of food N(N ≤ 100), on the next line prices of the each food type (price ≤1000) with a single space, on the next line the number of teachers, on the next lines the name of the teacher and the following line the number of portion(s) of each food. If the food has not, there is written 0 (zero).

Output specification
on the first line show the total money spent, and on the following lines show the list of teachers from the most payers to the least payers. If the amount of the money paid by teachers is equal, show them in order of input.

 Sample Input I     Sample Input II   
 3
 50 100 150
 2
 Alban
 1 0 1
 Ylber
 0 2 1
 5
 10 20 30 40 50
 4
 Ali
 1 0 0 0 0
 Rovsen
 0 2 0 0 1
 Yusuf
 0 0 1 1 0
 Kilicbek
 1 1 1 1 1
 Sample Output I     Sample Output II   
 550
 Ylber
 Alban

 320
 Kilicbek
 Rovsen
 Yusuf
 Ali


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

www.contester.ru