Вы находитесь на странице: 1из 2

Problem Statement Warning: This problem statement contains superscripts and/or subscripts.

. It may not display properly outside of the applet. The candy industry is going through a hard time in Byteland. Some of the bigges t companies in the business have decided to perform a series of mergers so as to become one company in the end. Due to the depression, each merger should join a t least k companies at once. Surprisingly, empirical studies conducted by the ec onomists of Byteland have shown that the revenue of a company that is created by simultainously merging m (m >= k) companies with revenues equal to r0, r1, ..., rm - 1 is equal to the average of these revenues, that is (r0 + r1 + ... + rm 1) / m. You are given a vector <int> revenues. The revenue of the i-th of the companies that want to merge is equal to revenues[i]. Return the maximum possibl e revenue of the final company that can be created in any series of mergers that joins all the companies. Definition Class: MergersDivTwo Method: findMaximum Parameters: vector <int>, int Returns: double Method signature: double findMaximum(vector <int> revenues, int k) (be sure your method is public) Notes The returned value must have an absolute or relative error less than 10-9. Please note that the revenue of a company may be negative; this means that the c ompany is actually losing money. It is always possible to merge all companies into a single one: for example, by merging all of them in a single step. Constraints revenues will contain between 2 and 50 elements, inclusive. Each element of revenues will be between -1,000 and 1,000, inclusive. k will be between 2 and the number of elements in revenues, inclusive. Examples 0) {5, -7, 3} 2 Returns: 1.5 The optimal way is to first merge companies 1 and 2, obtaining a company with to tal revenue -2, and then merge that company with company 0. 1) {5, -7, 3}

3 Returns: 0.3333333333333333 The respective revenues are the same as in the previous example, but because k = 3, we have to merge all companies at once. 2) {1, 2, 2, 3, -10, 7} 3 Returns: 2.9166666666666665 The solution is to first merge companies 0, 1, 2 and 4, and then merge the resul ting company with companies 3 and 5. 3) {-100, -100, -100, -100, -100, 100} 4 Returns: -66.66666666666667 Note that we can't merge less than six companies in the first step, because othe rwise we would be left with only two or three companies and we would be unable t o finish the merging process. 4) {869, 857, -938, -290, 79, -901, 32, -907, 256, -167, 510, -965, -826, 808, 890, -233, -881, 255, -709, 506, 334, -184, 726, -406, 204, -912, 325, -445, 440, -3 68} 7 Returns: 706.0369290573373 This problem statement is the exclusive and proprietary property of TopCoder, In c. Any unauthorized use or reproduction of this information without the prior wr itten consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.

Вам также может понравиться