. Line to Cashier

本文介绍了一种算法,用于解决在超市收银台选择最优队列的问题,通过计算每个队伍的等待时间来帮助顾客快速完成结账。
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 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 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 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<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,i,j;
    int a[105];
    int b[105];
    int c[105];
    while(cin>>n)
    {

        for(i=0;i<n;i++)
            cin>>a[i];
            for(j=0;j<n;j++)
            {
                int sum=0;
                for(i=0;i<a[j];i++)
                {
                    cin>>b[i];
                    sum=sum+(b[i]*5+15);
                }
                c[j]=sum;
            }
            sort(c,c+n);
            cout<<c[0]<<endl;
    }
    return 0;
}


 

将这个请求头和请求体生成链接: :authority: thor.weidian.com :method: POST :path: /cashier/pay.pre/1.0 :scheme: https content-length: 1239 accept: application/json, text/plain, */* user-agent: Mozilla/5.0 (Linux; Android 12; AOSP Build/SQ1A.220205.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/101.0.4951.61 Mobile Safari/537.36 V1_AND_SQ_9.1.70_9898_YYB_D QQ/9.1.70.25645 NetType/WIFI WebP/0.4.1 AppId/537285986 Pixel/720 StatusBarHeight/49 SimpleUISwitch/0 QQTheme/1000 StudyMode/0 CurrentMode/0 CurrentFontScale/1.0 GlobalDensityScale/0.9 AllowLandscape/true InMagicWin/0 content-type: application/x-www-form-urlencoded origin: https://weidian.com x-requested-with: com.tencent.mobileqq sec-fetch-site: same-site sec-fetch-mode: cors sec-fetch-dest: empty referer: https://weidian.com/ accept-encoding: gzip, deflate accept-language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7 cookie: wdtoken=900cd43d cookie: __spider__visitorid=ed1bc469de9424ed cookie: __spider__sessionid=f6cbbd85263f46d0 cookie: smart_login_type=0 cookie: login_token=_EwWqqVIQL4BWEH1YXzByOWpEm7mLVDEy0BBPZ453Mivf6wJ0NrfuLDf3iw94rWYbWC3GrMby__pjWjwYv6MU_O-pNyhulQHrgpYZFfoHL8NAjD6t9J9_eCBAcHSgI_9k8GNrjKegkHKfy1lHriLJTDn35dtq3HIweV1j7Tq0uF0E3ewKULdVzpcEmYy0R7iJ7WG1RbrI69_sAb3Os-lIDF7FojoJzuryam9DPccvmovos-NMGAcSFA6ubtB_oPuPM5iUFmUX cookie: is_login=true cookie: login_type=LOGIN_USER_TYPE_MASTER cookie: login_source=LOGIN_USER_SOURCE_MASTER cookie: uid=1523232406 cookie: duid=1523232406 cookie: sid=1693416972 cookie: cashier_token=829e69b1b1651d66a69a94813a1f2582 请求体: param=%7B%22ct%22%3A%223RtmTB4Ks%2F8o%2FR03GGY6wAFzeRKtINBDTnGOOJvnJpU%3D%22%2C%22token%22%3A%22C4033994326%22%2C%22from%22%3A%22H5%22%2C%22platForm%22%3A%22browser%22%2C%22environment%22%3A%22QQ%22%2C%22appVersion%22%3A%22%22%2C%22orderAmount%22%3A%226325.00%22%2C%22isMall%22%3A0%2C%22entrance%22%3A%22common_cashier%22%2C%22instCode%22%3A%22QWPAY%22%2C%22dbcr%22%3A%22GC%22%2C%22payMode%22%3A%22ONLINE_BANK%22%2C%22concession%22%3Atrue%2C%22clientExt%22%3A%7B%22deviceType%22%3A%22H5%22%2C%22payTypeFrom%22%3A%22payCashier%22%2C%22userAgent%22%3A%22Mozilla%2F5.0%20%28Linux%3B%20Android%2012%3B%20AOSP%20Build%2FSQ1A.220205.002%3B%20wv%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Version%2F4.0%20Chrome%2F101.0.4951.61%20Mobile%20Safari%2F537.36%20V1_AND_SQ_9.1.70_9898_YYB_D%20QQ%2F9.1.70.25645%20NetType%2FWIFI%20WebP%2F0.4.1%20AppId%2F537285986%20Pixel%2F720%20StatusBarHeight%2F49%20SimpleUISwitch%2F0%20QQTheme%2F1000%20StudyMode%2F0%20CurrentMode%2F0%20CurrentFontScale%2F1.0%20GlobalDensityScale%2F0.9%20AllowLandscape%2Ftrue%20InMagicWin%2F0%22%2C%22shopType%22%3A%22normal%22%2C%22isMobile%22%3Afalse%2C%22entrance%22%3A%22common_cashier%22%2C%22itemIds%22%3A%227334049825%22%7D%7D&v=1.0&timestamp=1746784136893
最新发布
05-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值