CF408A.Line to Cashier

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn cashiers at the exit from the supermarket. At the moment the queue for the ii -th cashier already has kik_{i} people. The jj -th person standing in the queue to the ii -th cashier has mi,jm_{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.

输入格式

The first line contains integer nn ( 1<=n<=1001<=n<=100 ) — the number of cashes in the shop. The second line contains nn space-separated integers: k1,k2,...,knk_{1},k_{2},...,k_{n} ( 1<=ki<=1001<=k_{i}<=100 ), where kik_{i} is the number of people in the queue to the ii -th cashier.

The ii -th of the next nn lines contains kik_{i} space-separated integers: mi,1,mi,2,...,mi,kim_{i,1},m_{i,2},...,m_{i,ki} ( 1<=mi,j<=1001<=m_{i,j}<=100 ) — the number of products the jj -th person in the queue for the ii -th cash has.

输出格式

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

输入输出样例

  • 输入#1

    1
    1
    1
    

    输出#1

    20
    
  • 输入#2

    4
    1 4 3 2
    100
    1 2 2 3
    1 9 1
    7 8
    

    输出#2

    100
    

说明/提示

In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 1005+15=515100·5+15=515 seconds. But if he chooses the second queue, he will need 15+25+25+35+415=1001·5+2·5+2·5+3·5+4·15=100 seconds. He will need 15+95+15+315=1001·5+9·5+1·5+3·15=100 seconds for the third one and 75+85+215=1057·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.

首页