题目连接:http://codeforces.com/problemset/problem/408/A
题目描述
Description
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 the j-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 Input
1
1
1
Sample Output
20
Sample Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Sample Output
100
解题思路
题意:去超市买东西,计算哪个人最快结完账,每件需要5秒扫码,找零需要15秒。
边输入边计算出时间,然后记录时间,每次计算出比较出小的保留。
注意初始化,和每个数据输入时是否输对位。
AC代码
#include<iostream>
#include<algorithm>
using namespace std;
int k[110];
int mixn = 99999999;
int main () {
int n, t, t1;
cin >> n;
for(int i = 1; i <= n; i++)
cin >> k[i];
int sum, x;
for(int i = 1; i <= n; i++) {
sum = k[i] * 15;
for(int j = 1; j <= k[i]; j++) {
cin >> x;
sum += x * 5;
}
if(sum < mixn) mixn = sum;
}
printf("%d\n", mixn);
return 0;
}