#P3606. [USACO17JAN] Building a Tall Barn P
[USACO17JAN] Building a Tall Barn P
题目描述
Farmer John is building a brand new, -story barn, with the help of his cows ( and ). To build it as quickly as possible, he needs your help to figure out how to allocate work among the cows.
Each cow must be assigned to work on exactly one specific floor out of the total floors in the barn, and each floor must have at least one cow assigned to it. The th floor requires units of total work, and each cow completes one unit of work per hour, so if cows work on floor , it will be completed in units of time. For safety reasons, floor must be completed before construction can begin on floor .
Please compute the minimum total time in which the barn can be completed, if the cows are allocated to work on floors in an optimal fashion. Output this number rounded to the nearest integer; it is guaranteed that the solution will be more than 0.1 from the boundary between two integers.
输入格式
The first line of input contains and .
The next lines contain , each a positive integer of size at most .
输出格式
Please output the minimum time required to build the barn, rounded to the
nearest integer.
题目大意
题目大意
FJ 正在他的 头奶牛的帮助下建造一个全新的 层谷仓()。为了能够尽快的建造它,他需要你帮助他来找出如何在奶牛间分配工作。
每一头牛必须分配到 层中的某一个特定楼层中,并且每一层楼必须至少有一头牛在其中工作。第i层楼需要 个单位的工作,并且每一头牛完成每一单位的工作需要一个单位时间。所以如果有 头牛在第 层工作,那么第 层需要 个单位时间。为了安全起见,在开始施工第 层楼之前,必须先完成第 层。
如果奶牛被分配以最佳方式在楼层上工作,请计算完成谷仓的最小总时间。输出这个时间四舍五入到整数的结果;数据保证答案离两个整数间的中界大于 。
输入格式
第一行包括两个数 和 。
接下来 行包括了,每行一个不大于 的正整数。
输出格式
请输出完成谷仓的最小总时间(四舍五入至整数)。
by @Happy_mouse
2 5
10
4
5