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
|
Для отправки решений необходимо выполнить вход.
|