3262.Line to Cashier

Time Limit: 1s Memory Limit: 256MB

Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.

There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi,j items in the basket. Vasya knows that:
the cashier needs 5 seconds to scan one item; after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.

Input Format(From the terminal/stdin)

The first line contains integer n (1 \le n \le 100)- the number of cashes in the shop. The second line contains n space-separated integers: k1,k2,...,kn (1 \le ki \le 100), where ki is the number of people in the queue to the i-th cashier.

The i-th of the next n lines contains ki space-separated integers: mi,1,mi,2,...,mi,ki (1 \le mi,j \le 100)- the number of products the j-th person in the queue for the i-th cash has.

Output Format(To the terminal/stdout)

Print a single integer - the minimum number of seconds Vasya needs to get to the cashier.

Sample Input 1

Copy
1
1
1
 \n
 \n
 \n

Sample Output 1

Copy
20
  \n

Sample Input 2

Copy
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
 \n
 · · · \n
   \n
 · · · \n
 · · \n
 · \n

Sample Output 2

Copy
100
   \n

Hints

In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100 \cdot 5+15=515 seconds. But if he chooses the second queue, he will need 1 \cdot 5+2 \cdot 5+2 \cdot 5+3 \cdot 5+4 \cdot 15=100 seconds. He will need 1 \cdot 5+9 \cdot 5+1 \cdot 5+3 \cdot 15=100 seconds for the third one and 7 \cdot 5+8 \cdot 5+2 \cdot 15=105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue.

Submit

请先 登录

© 2025 FAQs