Description: acm算法设计
描述:
设有n 个顾客同时等待一项服务。顾客i需要的服务时间为ti ,1 < = i < = n 。应如何安排n个顾客的服务次序才能使平均等待时间达到最小?平均等待时间是n 个顾客等待服务时间的总和除以n。
对于给定的n个顾客需要的服务时间,编程计算最优服务次序。
输入:第一行是正整数n,表示有n 个顾客。接下来的1行中,有n个正整数,表示n个顾客需要的服务时间。
输出:最小平均等待时间
例输入:
10
56 12 1 99 1000 234 33 55 99 812
例输出:
532.00
-acm algorithm design Description: n has a customer waiting for a service at the same time. I need to service customers time ti, 1 < = i < = n. N how to arrange the order of a customer' s service to make the average waiting time to a minimum? Average waiting time is n-time customers wait for service by dividing the sum of n. N for a given month of the service needs of customers, the best services to the order of the calculation program. Input: the first line is a positive integer n, that there are n customer. 1 the next line, there is a positive integer n, that n of the service needs of customers. Output: the minimum average waiting time for cases of type: 10 56 12 1 99 1000 234 33 55 99 812 cases Output: 532.00 Platform: |
Size: 234496 |
Author:张波 |
Hits: