HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50525 - Ordering Pizza

Guest
• Review clarifications (1)

Volume problems

• 50847 - The first m trains to leave
• 50669 - Area of an Irregular Polygon
• 50860 - Number of Student Certificates
• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 51011 - Decoding the Path
• 51019 - Finding the hidden message
• 51002 - The most successful classes
• 50525 - Ordering Pizza
• 50342 - 100 Factorial
• 50524 - Elevator
• 50531 - File Decryption
• 50758 - National Elections - Revisited
• 50687 - Pascal Triangle - 2
• 50756 - Average of the Nth Student
• 50457 - The Number of Winners
• 50752 - Student Groups

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 Ibrahim Mesecan.

Ordering Pizza

You are asked to write a program for a pizza shop. They have a price list for the pizzas and they store the orders coming from clients in a file. In the evenings, they want to check for the balance.

Question: Write a program that will read the pizza information and calculate the daily balance.

Input specification
First, you will be given an integer (n) the number of pizza types. Then, in the following line, you are given n inetgers. The first number is the price of first type of pizza, etc.

Then starting from the third line, in every line, you are given the orders of a customer. Every line contains an integer (k) at the beginning, then you are given k pairs of numbers in that line. In every pair, the first number is the type of the pizza and the second number represent the amount ordered by the customer from this type. Every pair ends with a semicolon. And the file end with a negative number at the beginning of the line where 1 ≤ n ≤ 100, and 1 ≤ k ≤ 60 and there are at most 6000 customer information.

Output specification
Show two integers, total balance of the day and the Max amount from one customer.

Sample Input I
5
200 250 300 350 400
1 1 2;
4 4 4; 5 3; 1 1; 3 2;
2 2 3; 5 2;
2 3 4; 2 3;
-1
Sample Output I
7300 3400

Explanation: There are five types of Pizza and four customer information:

  • The first customer bought only one type of pizza: 200x2=400
  • The second customer bought 4 types of pizza: 350x4 + 400x3 + 200x1 + 300x2 = 3400
  • The third customer bought 2 types of pizza: 1550
  • The fourth customer bought 2 types of pizza: 1950
And so, the total is 7300 and the second client has bought the max amount with 3400.


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

www.contester.ru