Codeforces Round #239 (Div. 2) A. Line to Cashier(简单题)

1、http://codeforces.com/contest/408/problem/A

2、题目大意:

现在有n个队可以结账,每个队现在有ki个人,每个人有m件物品等待结账,每件物品结账5秒,每个人最终交钱需要15秒,求最快的结完账的队需要多长时间

题目很简单直接计算就行

3、题目:

A. Line to Cashier
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 thei-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier hasmi, 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 containsn space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), whereki is the number of people in the queue to thei-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 the j-th person in the queue for thei-th cash has.

Output

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

Sample test(s)
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note

In the second test sample, if Vasya goes to the first queue, he gets to the cashier in100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and7·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.

4、AC代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define INF 0x7fffffff
int a[105];
int main()
{
    int n,b,sum;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        int minn=INF;
        for(int i=1;i<=n;i++)
        {
            sum=0;
            for(int j=1;j<=a[i];j++)
            {
                scanf("%d",&b);
                sum+=b;
            }
            sum=sum*5+a[i]*15;
            if(sum<minn)
            minn=sum;
        }
        printf("%d\n",minn);
    }
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值