StopCard
시간 제한1초메모리 제한1024 MB
서로 다른 n개의 카드 값과 기준 c가 주어질 때, 기록 갱신 시 멈추는 전략의 기대 점수를 모든 무작위 순열에 대해 계산한다.
문제
Jacob is playing a very odd solo card game called StopCard. In this game, the deck consists of cards where every card has one unique integer written on one side of it. The deck is shuffled randomly before the game is played. During each turn of the game, Jacob can choose to either take a card off the top of the deck and read that value, or not take a card off the deck and end the game. His final score for the game is the value of the last card taken from the deck. The deck will always have at least one card, and the first turn of the game must always be to draw the top card of the deck.
Jacob has a basic understanding of optimal stopping theory, so he devises a plan to play the game somewhat effectively. His plan is to keep drawing cards for a predetermined number () of times, then to keep going until he sees a card that is larger than all the cards he previously saw, then to stop. His score will be the value written on that card. If he never sees a larger value on a card than the first cards he skipped, he would continue drawing until the deck runs out and would be left with a score equal to the number on the last card in the deck.
What is Jacob's expected score under this strategy?
입력
The input consists of a single test case. The first line contains two integer numbers and denoting the number of cards in the deck () and is the number of cards Jacob will definitely draw (). The second line contains distinct integer numbers () - the numbers written on the cards in the deck, which may be given in any order.
출력
Output the expected score under Jacob's strategy. Your answer will be considered correct if its absolute or relative error does not exceed .