codeforces. problem/408/A
来源:互联网 发布:新手怎么做淘宝 编辑:程序博客网 时间:2024/04/29 14:13
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.
111
20
41 4 3 21001 2 2 31 9 17 8
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.
#include <string.h>#include <stdio.h>#include <algorithm>#include <iostream>using namespace std;int a[105],b[105][105],sum[105];int main(){ int n; while(~scanf("%d",&n)) { memset(sum,0,sizeof(sum)); for(int i=0;i<n;i++) cin >> a[i]; for(int i=0;i<n;i++) { for(int j=0;j<a[i];j++) { cin >> b[i][j]; sum[i]+=b[i][j]*5; } sum[i]+=a[i]*15; } sort(sum,sum+n); printf("%d\n",sum[0]); } return 0;}
- codeforces. problem/408/A
- Problem - 152A - Codeforces
- codeforces problem/244/A
- codeforces problem/415/A
- Codeforces Problem 333A
- Codeforces Problem 332A
- codeforces problem/416/A 二分
- codeforces 17A Noldbach problem
- 【codeforces 29A】Spit Problem
- CodeForces - 29A - Spit Problem
- CodeForces-17A-Noldbach problem
- 【codeforces 749A】Bachgold Problem
- Codeforces 749A-Bachgold Problem
- Problem--1A--Codeforces--TheatreSquare
- Problem--4A--Codeforces--Watermelon
- Problem--231A--Codeforces--Team
- Problem--282A--Codeforces--BIt++
- Problem--96A--Codeforces--Football
- vim:打造Linux程序员的编辑利器(ctags+cscope+taglist+code_complete)
- 计算机视觉的一些测试数据集和源码站点
- 大四狗闲的没事,设计实现SPRING 的BEANFACTORY
- Android处理图片OOM的若干方法小结
- Runtime Error小结
- codeforces. problem/408/A
- iOS ---core data,sqlite,fmdb
- java多线程
- 在线学习
- Web App 页面构建的一般性规律
- 基础类BaseViewController(未验证了)
- C语言运算符优先级与结合方向
- Java防止非法和重复表单提交的分析
- 约你在春里,谈一场花絮情缘