QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#1697. Balance Beam

الإحصائيات

In order to save money for a new stall in her barn, Bessie the cow has started performing in the local circus, demonstrating her remarkable sense of balance as she carefully walks back and forth on an elevated balance beam!

The amount of money Bessie earns in her performance is related to where she manages to ultimately jump off the beam.
The beam has positions labeled $0, 1, \ldots, N+1$ from left to right.
If Bessie ever reaches $0$ or $N+1$ she falls off one of the ends of the beam and sadly gets no payment.

If Bessie is at a given position $k$, she can do either of the following:

  1. Flip a coin. If she sees tails, she goes to position $k-1$, and if she sees heads, she goes to position $k + 1$ (i.e. $\frac{1}{2}$ probability of either occurrence).
  2. Jump off the beam and receive payment of $f(k)$ $(0 \leq f(k) \leq 10^9)$.

Bessie realizes that she may not be able to guarantee any particular payment outcome, since her movement is governed by random coin flips. However, based on the location where she starts, she wants to determine what her expected payment will be if she makes an optimal sequence of decisions ("optimal" meaning that the decisions lead to the highest possible expected payment). For example, if her strategy earns her payment of $10$ with probability $1/2$, $8$ with probability $1/4$, or $0$ with probability $1/4$, then her expected payment will be the weighted average $10(1/2) + 8(1/4) + 0(1/4) = 7$.

Input Format

The first line of input contains $N$ ($2 \leq N \leq 10^5$). Each of the remaining $N$ lines contain $f(1) \ldots f(N)$.

Output Format

Output $N$ lines. On line $i$, print out $10^5$ times the expected value of payment if Bessie starts at position $i$ and plays optimally, rounded down to the nearest integer.

Sample Input

2
1
3

Sample Output

150000
300000

Problem credits: Franklyn Wang and Spencer Compton

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.