Problem:
 Score : 400 points    Problem Statement You are given N items. The value of the i -th item (1 \leq i \leq N) is v_i . Your have to select at least A and at most B of these items. Under this condition, find the maximum possible arithmetic mean of the values of selected items. Additionally, find the number of ways to select items so that the mean of the values of selected items is maximized.      Constraints  1 \leq N \leq 50  1 \leq A,B \leq N  1 \leq v_i \leq 10^{15}  Each v_i is an integer.         Input The input is given from Standard Input in the following format:  N  A  B  v_1  v_2 ... v_N       Output Print two lines. The first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6} . The second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.        Sample Input 1 5 2 2
1 2 3 4 5      Sample Output 1 4.500000
1  The mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5 . There is no other way to select items so that the mean of the values will be 4.5 , and thus the second line of the output should contain 1 .       Sample Input 2 4 2 3
10 20 10 10      Sample Output 2 15.000000
3  There can be multiple ways to select items so that the mean of the values will be maximized.       Sample Input 3 5 1 5
1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996      Sample Output 3 1000000000000000.000000
1

Solution (Python):
class Frac(object):
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def eq(self, f):
        return self.a * f.b == f.a * self.b

    def lt(self, f):
        return self.a * f.b > f.a * self.b

    def __repr__(self):
        return '%.6f' % (self.a / self.b)


def factorial(n):
    res = 1
    for i in range(n):
        res *= i+1
    return res


def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)


N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)

res = None
for i in range(A, B+1):
    now = Frac(sum(V[:i]), i)
    if res is None or now.lt(res[0]):
        res = [now]
    elif now.eq(res[0]):
        res.append(now)

cnt = 0
for now in res:
    p = V[:now.b]
    n = len(list(filter(lambda x: x == p[-1], V)))
    r = len(list(filter(lambda x: x == p[-1], p)))
    cnt += nCr(n, r)

print(res[0])
print(cnt)

Solution (Python):
def combination(n, r):
    res = 1
    t = r - 1
    while t >= 0:
        res = res * (n - t) // (r - t)
        t -= 1
    return res

n,a,b = map(int, input().split())
v = list(map(int, input().split()))

v.sort()
v.reverse()

t = 0
for i in range(a):
    t += v[i]
t /= a
print(t)

cnt = 0
if v[0] == v[a-1]:
    candidate = 0
    cnt = 0
    for i in range(n):
        if v[i] == v[0]:
            candidate += 1
        else:
            break
    for i in range(a, min(b, candidate)+1):
        cnt += combination(candidate, i)
else:
    cnt = 0
    first = 50
    last = 0
    for i in range(n):
        if v[i] == v[a-1]:
            first = min(i, first)
            last = max(i, last)
    candidate = last - first + 1
    cnt += combination(candidate, a-first)
print(cnt)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def nCb(n, b):
    if b > n - b:
        b = n - b
    r = 1
    for k in range(n, n-b, -1):
        r = r * k
    d = 1
    for k in range(1, b+1):
        d = d * k
    return r // d

def main():
    n,a,b = LI()
    v = sorted(LI(),reverse=True)
    if v[0] == v[a-1]:
        t = a-1
        for i in range(a,n):
            if v[0] != v[i]:
                break
            t = i
        t += 1
        r = 0
        for i in range(a,min(b,t)+1):
            r += nCb(t,i)
        return "{}\n{}".format(v[0], r)

    t = 0
    tu = 0
    va = v[a-1]
    for i in range(n):
        if v[i] > va:
            tu += 1
        elif v[i] == va:
            t += 1
        else:
            break
    r = nCb(t,a-tu)
    return "{}\n{}".format(sum(v[:a]) * 1.0 / a, r)



print(main())

Solution (Python):
import sys

stdin = sys.stdin


def na(): return map(int, stdin.readline().split())


def ns(): return stdin.readline().strip()


n,a,b=na()
v = list(na())
v.sort()
tot = 0
last = 0
for i in range(a):
    tot += v[-(i+1)]
    last = v[-(i+1)]

com = []
q = 100
for i in range(q):
    com.append([0]*q)

for i in range(q):
    com[i][0] = 1
    for j in range(1, q):
        com[i][j] = com[i-1][j-1] + com[i-1][j]

print("{:.9f}".format(tot/a))
lct = 0
large = 0
for w in v:
    if w > last:
        large += 1
    if w == last:
        lct += 1
ret = 0
if large == 0:
    for i in range(a,b+1):
        if 0 <= i-large <= lct:
            ret += com[lct][i-large]
else:
    ret = com[lct][a-large]
print(ret)