CF408A.Line to Cashier

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

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

小瓦西娅去超市购买一些杂货。他在超市里逛了很长时间,买了一篮子商品。现在他需要选择一个收银台来付款。

超市出口处共有 nn 个收银台。当前第 ii 个收银台前的队伍中已有 kik_i 人。排在第 ii 个收银台队伍中第 jj 位的顾客,其购物篮中有 mi,jm_{i,j} 件商品。瓦西娅知道:

  • 收银员扫描一件商品需要 5 秒;
  • 收银员扫描完某位顾客的所有商品后,还需额外花费 15 秒来收取该顾客的款项并找零。

当然,瓦西娅希望选择一个队列,以便能尽快离开超市。请帮他编写一个程序,输出瓦西娅到达任一收银台所需的最短时间(单位:秒)。

输入格式

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.

第一行包含一个整数 nn(1≤n≤1001 \leq n \leq 100)—— 商店中收银台的数量。
第二行包含 nn 个用空格分隔的整数:k1, k2, …, knk_1,\,k_2,\,\dots,\,k_n(1≤ki≤1001 \leq k_i \leq 100),其中 kik_i 表示第 ii 个收银台前排队的人数。

接下来的 nn 行中,第 ii 行包含 kik_i 个用空格分隔的整数:mi,1, mi,2, …, mi,kim_{i,1},\,m_{i,2},\,\dots,\,m_{i,k_i}(1≤mi,j≤1001 \leq m_{i,j} \leq 100)—— 表示第 ii 个收银台队列中第 jj 个人所购商品的数量。

输出格式

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

输出一个整数——Vasya 到达收银台所需的最少秒数。

输入输出样例

  • 输入#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 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.

在第二个测试样例中,如果瓦西娅选择第一个队列,他将在 100⋅5 + 15 = 515100\cdot5\,+\,15\,=\,515 秒后到达收银台。但如果他选择第二个队列,则需要 1⋅5 + 2⋅5 + 2⋅5 + 3⋅5 + 4⋅15 = 1001\cdot5\,+\,2\cdot5\,+\,2\cdot5\,+\,3\cdot5\,+\,4\cdot15\,=\,100 秒;选择第三个队列则需要 1⋅5 + 9⋅5 + 1⋅5 + 3⋅15 = 1001\cdot5\,+\,9\cdot5\,+\,1\cdot5\,+\,3\cdot15\,=\,100 秒;而选择第四个队列则需要 7⋅5 + 8⋅5 + 2⋅15 = 1057\cdot5\,+\,8\cdot5\,+\,2\cdot15\,=\,105 秒。因此,瓦西娅选择第二个或第三个队列时能更快到达收银台。

输入解题思路,AI测评打分。不知道怎么写?

首页