Codeforces Round 239 (Div. 2)
A
Line to Cashier
Codeforces
900
原题
←B →
翻译中…

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 $*k*_{*i*}$ people. The $*j*$-th person standing in the queue to the $*i*$-th cashier has $*m*_{*i*, *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

翻译中…

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 100$) — the number of cashes in the shop. The second line contains $*n*$ space-separated integers: $*k*_{1}, *k*_{2}, ..., *k*_{*n*}$ ($1 ≤ *k*_{*i*} ≤ 100$), where $*k*_{*i*}$ is the number of people in the queue to the $*i*$-th cashier.

翻译中…

The $*i*$-th of the next $*n*$ lines contains $*k*_{*i*}$ space-separated integers: $*m*_{*i*, 1}, *m*_{*i*, 2}, ..., *m*_{*i*, *k*_{*i*}}$ ($1 ≤ *m*_{*i*, *j*} ≤ 100$) — the number of products the $*j*$-th person in the queue for the $*i*$-th cash has.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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

翻译中…

样例

Input #1
1
1
1
Output #1
20
InputCopy OutputCopy
Input #2
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output #2
100
InputCopy OutputCopy
题目信息
题号
408A
时间限制
1 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。