1500: 银行服务

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:57 通过:27

题目描述

Assuming the bank has 2 service windows, n customers will arrive one after another and queue up for service one meter away.

Assuming that the time required by the bank to serve each customer (within the range of [1100]) is known. Whenever a window is available, the next customer walks to that window (this time interval is ignored) and the bank staff serves that customer. Ask the bank how long it will take to serve these customers in total.




假设银行有2个服务窗口,n个客户陆续到来并在一米线外排队等候服务。
假设银行为每个客户服务所需的时间(范围在[1,100])是已知的。每当有一个窗口空闲时,下一个顾客则走到该窗口(这个时间间隔是忽略的),银行职员为该客户服务。问银行为这些客户服务总共需要多长时间。


如输入5 1 3 3 5 7
5表示有5个客户,后面5个整数表示这5个客户的服务时间。假设第1个顾客选择1号窗口(图中左边的窗口),第2个顾客选择2号窗口,那第3个顾客必然选择第1个窗口,第4个顾客选择2号窗口,第5个顾客选择1号窗口。当银行结束第5个客户的服务时,总共用时为11

输入格式

输入文件中包含多个测试数据。每个测试数据占一行,首先是一个自然数nn≤100,然后是n个自然数。输入文件最后一行为0,表示输入结束。

输出格式

对输入文件中的每个测试数据,计算总用时并输出。

输入样例 复制

5 1 3 3 5 7
0

输出样例 复制

11

分类标签