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.
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.
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Sample test(s)
input
111
output
20
input
41 4 3 21001 2 2 31 9 17 8
output
100
解题报告:模拟题,大意是有n个收银员,每个收银员有k个顾客,每个顾客买了m[i][j]件商品,收银员每扫描一件商品花5秒钟,结算花15秒。计算哪一队的时间最短。假设时间为t,那么:t=这队的总人数*15+所有商品数*5;最后min(t)即可。
参考的代码:
#include <iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int p[100][100],c[100];
int main()
{
//freopen("in.txt","r",stdin);
int i,j,k,m,n,s;
while(cin>>n)
{
int min_s=999999999;
for(i=0;i<n;i++)
cin>>c[i];
for(i=0;i<n;i++)
for(j=0;j<c[i];j++)
{
cin>>p[i][j];
}
for(i=0;i<n;i++)
{
s=0;
for(j=0;j<c[i];j++)
{
s+=p[i][j]*5;
}
s+=c[i]*15;
if(s<min_s)
min_s=s;
}
cout<<min_s<<endl;
}
return 0;
}