Coconuts

시간 제한3초메모리 제한2048 MB

요약
코코넛별 내구도는 알지만 어느 코코넛이 어느 내구도인지 모를 때, 정확히 k번의 타격으로 깨뜨릴 수 있는 코코넛 수의 기댓값을 최대로 만든다.
난이도

어려움10점 중 8점

유형
동적 계획법, 확률, 그리디
정답자
아직 제출이 없습니다

문제

Consider nn coconuts and an array dd describing them. The value d_id\_i is the durability of the ii-th coconut. It means that the ii-th coconut will be cracked after d_id\_i hits.

Then the coconuts were shuffled, so it is now impossible to determine which coconut has which durability.

Your goal is to crack as many coconuts as possible using exactly kk hits. What is the expected number of cracked coconuts if you use the best possible strategy?

For each hit, you can arbitrarily select one coconut and hit it. After that, you see if the coconut has cracked or not.

입력

The first line contains two integers nn and kk: the number of coconuts and the number of hits required, respectively.

The second line contains nn integers d_1,d_2,…,d_nd\_1, d\_2, \ldots, d\_n: durabilities of coconuts.

출력

Output one real number which denotes the expected number of cracked coconuts if you use the best possible strategy. The relative or absolute error of the result should not exceed 10−610^{-6}.

제한

  • 1≤n≤101 \leq n \leq 10;
  • 1≤d_i≤101 \leq d\_i \leq 10;
  • 1≤k≤∑_i=1nd_i1 \leq k \leq \sum\limits\_{i=1}^n d\_i.

힌트

Here are the best strategies for examples:

  1. Hit a random coconut, then hit another one.
  2. Choose a coconut, hit it until it cracks, then switch to another until it cracks, etc.

예제2

  1. 예제 1

    입력
    3 2
    1 3 3
    
    예상 출력
    0.666666666667
    
  2. 예제 2

    입력
    4 5
    2 2 3 3
    
    예상 출력
    1.833333333333