A. Line to Cashier

来源:互联网 发布:nginx 禁止某个ip访问 编辑:程序博客网 时间:2024/05/31 18:33

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

The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 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 ≤ mi, j ≤ 100) — the number of products thej-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.

Sample test(s)
input 2 1 2 1 2 3  output20 解题思路---------开始觉得应该会用很多循环,自己尝试了,,怎样才能让n个数,输出,再由输出的数在输出相应的个数,然后本想尽量能让程序简单点,但自己知道的算法太少了,所以用了最笨的方法算的。而且由于编译器新下的原因。不会用,用自己仅只道的几个英文竟然能倒弄明白,我用了三个循环,一个冒泡排序,还是弄出来了。

#include<stdio.h>
 
 int main()
{int a,b,d,c[100],e,sum[100],k,g,f[100],j,y,ss,i,m[100];
while(scanf("%d",&a)!=EOF)
{
for(b=1;b<=a;b++)
{scanf("%d",&c[b]);}

for(k=1;k<=a;k++)
{y=0;
for(g=1;g<=c[k];g++)
{
scanf("%d",&f[g]);
y+=f[g];}
sum[k]=y;}

for(e=1;e<=a;e++)
{m[e]=c[e]*15+sum[e]*5;}
for(i=1;i<a;i++)
{for(j=i+1;j<=a;j++)
{if(m[i]>m[j])
{ss=m[i];
m[i]=m[j];
m[j]=ss;
}}}printf("%d",m[1]);}return 0;}这道题1懂得define用法2一些循环方式         虽然知道题用的方法很笨(了解其他方法),但还是弄出来了,当看到ac时,眼睛里却沾上水。也是自己效率的问题,不过谢谢自己坚持把这道题弄出来。


0 0
原创粉丝点击