각 위치에서 상금 f(k)를 받고 내려올 수 있고 한 걸음마다 좌우로 1/2 확률로 움직일 때, 각 시작 위치에서 최적 전략의 기댓값을 구한다.
어려움8동적 계획법수학아직 제출이 없습니다시간 제한2초메모리 제한512 MBIn 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,…,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:
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.
The first line of input contains N (2≤N≤105). Each of the remaining N lines contain f(1)…f(N).
Output N lines. On line i, print out 105 times the expected value of payment if Bessie starts at position i and plays optimally, rounded down to the nearest integer.