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.
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.
#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时,眼睛里却沾上水。也是自己效率的问题,不过谢谢自己坚持把这道题弄出来。
- A. Line to Cashier
- A. Line to Cashier
- code forces 408A Line to Cashier
- codeores--A. Line to Cashier--3.30
- CF:Line to Cashier
- . Line to Cashier
- 【CodeForce #239 Div2】408A——Line to Cashier
- Codeforces Round #239 (Div. 2) A. Line to Cashier(简单题)
- Shell Script Utility To Read a File Line By Line
- How to read a file line by line?
- Passing Command Line Arguments to a Module
- append a string to each line
- How to remove a line from a file in java?
- 2.6. Passing Command Line Arguments to a Module
- A research line from cloud computing to hypergraph
- Java : how to draw a line in thickness
- PowerShell - How to enter a multi-line command
- How to display a line break with outputText?
- backtrace打印堆栈的信号问题
- java.lang.NullPointerException: Expected timestamp in the Flume event headers, but it was null
- C++ map的基本操作和使用
- Thinkpad X230 安装黑苹果 Mac OSX Mavericks 10.9.2
- strcpy和memcpy的区别
- A. Line to Cashier
- 前缀表达式
- 一步步学习微软InfoPath2010和SP2010--第十二章节--管理和监控InfoPath Form Services(IPFS)(3)--安装Fiddler并监控IPFS表单加载过程
- POJ 3243 大步小步算法
- 访问修饰符
- 如何在java程序中使用Xquery----datadirectxquery
- 腾讯2014年实习生招聘笔试面试经历
- 【GLSL教程】(五)卡通着色
- Hybrid开发 Sencha pinch事件的监听实现图片的缩放功能