TLE '17 Contest 4 P6 - Fax's Christmas Bash

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types
Fax and his wingmate Flaco enjoying the party.

Fax McClad, Croneria's most festive bounty hunter, is hosting a big Christmas party in his neighbourhood! His neighbourhood can be thought of as a straight line.

Fax has N crew members he can invite. The ith crew member is located xi metres to the east of the origin. He would like to invite some of his crew members to attend his party, but he wants to minimize the amount of time wasted. In particular, if the party is located y metres to the east of the origin, then the ith crew member will waste |xiy|3 time by going to the party.

Fax wants to invite all of his crew members to the party, but the total amount of time wasted might become too large. For each party size k, what is the best location to host the party if Fax only invites the first k crew members? In other words, what is the value of y that minimizes:

|x1y|3+|x2y|3++|xky|3

Note: y can be a real number.

Constraints

1N300000

The absolute value of any coordinate will not exceed 15000. That is, |xi|15000.

Subtask Points Additional Constraints
1 10 0xi1 for all 1iN
2 10 N30
3 20 N900
4 60 No additional constraints.

Input Specification

The first line will contain the integer N.

On the next N lines, the ith line will contain the integer xi.

Output Specification

There will be N lines of output. The kth line of output will contain the best location to host the party if the first k of Fax's crew members are invited.

Your output will be judged as correct if the absolute error does not exceed 103.

Sample Input

Copy
4
2823
5748
3092
-14068

Sample Output

Copy
2822.999999
4285.500000
4108.776249
-2600.293020

Comments


  • 4
    Beautiful_Times  commented on Jan. 17, 2018, 2:59 a.m.

    Is an editorial ever going to be released for this problem?