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



Sample input:
5 2 2
1 2 3 4 5


Sample output:
4.500000
1

Submission status: Wrong Answer

Solution code:
def fact(n):
    if n == 0:
        return 1
    else:
        return n*fact(n-1)
def conb(n,r):
    return fact(n)//(fact(r)*fact(n-r))

N,A,B = map(int,input().split())
v = list(map(int,input().split()))
v.sort()
v.reverse()
d_all = {}
for i in range(N):
    if v[i] not in d_all:
        d_all[v[i]] = 0
    d_all[v[i]] += 1
import numpy as np
avg = np.cumsum(np.array(v))
for i in range(N):
    avg[i]=int(avg[i])/(i+1)
avg = avg[A-1:B]
ans = max(avg)
print(ans)
indices = np.where(avg==ans)[0]
ans = 0
for index in indices:
    d_use = {}
    use = A + index
    v_use = v[:use]
    choose=1
    for item in v_use:
        if item not in d_use:
            d_use[item] = 0
        d_use[item] += 1
    for item in d_use:
        choose *= conb(d_all[item],d_use[item])
    ans += choose

print(ans)

Submission status: Wrong Answer

Solution code:
def inpl(): return [int(i) for i in input().split()]
def comb(a,b):
    return math.factorial(a)//math.factorial(a-b)//math.factorial(b)

N, A, B = inpl()
V = inpl()
V = list(reversed(sorted(V)))
x1 = N-1
x2 = 0
for i in range(N):
    if V[i] == V[A]:
        x1 = min(x1,i)
        x2 = max(x2,i)

print(sum(V[0:A])/A)
import math
ans = 0
if x1 == 0:
    for l in range(min(B-1,x2)-A+2):
        ans += comb(x2-x1+1,l-x1+1)
    print(ans)
else:
    print(comb(x2-x1+1,A-x1))

Submission status: Wrong Answer

Solution code:
def fact(n):
    if n == 0:
        return 1
    else:
        return n*fact(n-1)
def conv(n,r):
    return fact(n)//(fact(r)*fact(n-r))

N,A,B = map(int,input().split())
v = list(map(int,input().split()))
v.sort()
v.reverse()
d_all = {}
for i in range(N):
    if v[i] not in d_all:
        d_all[v[i]] = 0
    d_all[v[i]] += 1
import numpy as np
avg = np.cumsum(np.array(v))
n = np.arange(1,N+1)
avg = avg/n
avg = avg[A-1:B]
ans = max(avg)
print(ans)
indices = np.where(avg==ans)[0]
ans = 0
for index in indices:
    d_use = {}
    use = A + index
    v_use = v[:use]
    choose=1
    for item in v_use:
        if item not in d_use:
            d_use[item] = 0
        d_use[item] += 1
    for item in d_use:
        choose *= conv(d_all[item],d_use[item])
    ans += choose
    
print(ans)

Submission status: Wrong Answer

Solution code:
def inpl(): return [int(i) for i in input().split()]
def comb(a,b):
    return math.factorial(a)//math.factorial(a-b)//math.factorial(b)

N, A, B = inpl()
V = inpl()
V = list(reversed(sorted(V)))
x1 = N-1
x2 = 0
for i in range(N):
    if V[i] == V[A]:
        x1 = min(x1,i)
        x2 = max(x2,i)

print(sum(V[0:A])/A)
import math
ans = 0
if x1 == 0:
    for l in range(min(B-1,x2)-A+2):
        ans += comb(x2-x1+1,l-x1+1)
    print(ans)
else:
    print(comb(x2-x1+1,A-x1+1))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort()
v=v[::-1]
print(sum(v[:a])/a)
def com(x,y):
    a=1
    b=1
    y=min(y,x-y)
    for i in range(x,x-y,-1):
        a*=i
    for i in range(1,y+1):
        b*=i
    return a//b
ans=0
x=v.count(v[a-1])
y=v[:a].count(v[a-1])
if v[0]!=v[a]:
    ans+=com(x,y)
else:
    for j in range(a,b+1):
        ans+=com(x,j)
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort()
v=v[::-1]
print(sum(v[:a])/a)
def com(x,y):
    a=1
    b=1
    y=min(y,x-y)
    for i in range(x,x-y,-1):
        a*=i
    for i in range(1,y+1):
        b*=i
    return a//b
ans=0
if v[0]!=v[a]:
    ti,tj=0,0
    for i in range(n):
        if v[i]==v[-1]:
            ti+=1
    for j in range(a):
        if v[j]==v[-1]:
            tj+=1
    print(ti,tj)
    ans+=com(ti,tj)
else:
    ti=0
    for i in range(n):
        if v[i]==v[0]:
            ti+=1
    for j in range(a,b+1):
        ans+=com(ti,j)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from scipy.misc import comb

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

v.sort(reverse=True)
v_cum = []
num = 0
for i in range(n):
    num += v[i]
    v_cum.append(num)

print(v_cum[a-1]/a)

if a == n:
    print(1)
else:
    if v[a-1] == v[a]:
        num = v[a-1]
        cf = Counter(v[:a])
        cb = Counter(v[a:])
        n_cf = cf[num]
        n_cb = cb[num]
        if cf[num] != a:
            print(comb(n_cf+n_cb, n_cf, exact=True))
        else:
            ans = 0
            for k in range(a, a+n_cb+1):
                ans += comb(a+n_cb, k, exact=True)
            print(ans)
    else:
        print(1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from scipy.misc import comb

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

v.sort(reverse=True)
v_cum = []
num = 0
for i in range(n):
    num += v[i]
    v_cum.append(num)

print(v_cum[a-1]/a)

if a == n:
    print(1)
else:
    if v[a-1] == v[a]:
        num = v[a-1]
        cf = Counter(v[:a])
        cb = Counter(v[a:])
        n_cf = cf[num]
        n_cb = cb[num]
        if cf[num] != a:
            print(comb(n_cf+n_cb, n_cf))
        else:
            ans = 0
            for k in range(a, a+n_cb+1):
                ans += comb(a+n_cb, k)
            print(ans)
    else:
        print(1)

Submission status: Wrong Answer

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

v.sort(reverse=True)
for i in range(n-1):
    v[i+1] += v[i]
print(v[a-1]/a)

count = 1
if v[a-1] == v[0] * a:
    for i in range(a, b):
        if v[i] == v[0]*(i+1):
            count += 1
        else:
            break
print(count)

Submission status: Wrong Answer

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

v.sort(reverse=True)
for i in range(n-1):
    v[i+1] += v[i]
print(v[a-1]/a)

count = 1
if v[a-1] == v[0] * a:
    for i in range(a, b):
        if v[i] == v[0]:
            count += 1
        else:
            break
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
				
N,A,B=map(int,raw_input().split())

v=map(int,raw_input().split())

v.sort()
v=v[::-1]
ave_max=0
for i in range(A-1,B):
	ave_max=max(np.average(v[:i]),ave_max)
print ave_max
count=0
for i in range(A-1,B):
	if ave_max==np.average(v[:i]):
		count+=1
print count

Submission status: Wrong Answer

Solution code:
import numpy as np
				
N,A,B=map(int,raw_input().split())

v=map(int,raw_input().split())

v.sort()
v=v[::-1]
ave_max=0
for i in range(A,B+1):
	ave_max=max(np.average(v[:i]),ave_max)
print ave_max
count=0
for i in range(A,B+1):
	if ave_max==np.average(v[:i]):
		count+=1
print count

Submission status: Wrong Answer

Solution code:
# ABC 057 D
import math
N, A, B = map(int,input().split())
v = sorted(list(map(int,input().split())))[::-1]

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

a = sum(v[:A])/A
print(a)

s = 0
for k in range(N):
    if v[A-1] == v[k]:
        s += 1
t = 0
for k in range(A-1,B):
    if v[A-1] == v[k]:
        t += 1

if t == 1:
    print(1)
elif a != v[A-1]:
    print(s)
else:
    c = 0
    for k in range(t):
        c += nCr(s,k+1)
    print(c)

Submission status: Wrong Answer

Solution code:
# ABC 057 D
import math
N, A, B = map(int,input().split())
v = sorted(list(map(int,input().split())))[::-1]

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

a = sum(v[:A])/A
print(a)

s = 0
for k in range(N):
    if v[A-1] == v[k]:
        s += 1
t = 0
for k in range(A-1,B):
    if v[A-1] == v[k]:
        t += 1

if t == 0:
    print(1)
elif t >= 1 and a != v[A-1]:
    print(s)
else:
    c = 0
    for k in range(t):
        c += nCr(s,k+1)
    print(c)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
v = sorted(list(map(int, input().split())), reverse=True)

print('{:.6f}'.format(sum(v[:A]) / A))

x = v.count(v[A - 1])
y = v[:A].count(v[A - 1])
if v[0] != v[A - 1]:
    u = 1
    d = 1
    for i in range(x, x - y, -1):
        u *= i
    for i in range(y, 0, -1):
        d *= i
    print(u // d)
else:
    ans = 1
    for i in range(A, min(B, x) + 1):
        u = 1
        d = 1
        for j in range(x, x - i, -1):
            u *= j
        for j in range(i, 0, -1):
            d *= j
        ans += u // d
    print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
value = sorted(list(map(int, input().split())), reverse=True)
print('{:.6f}'.format(sum(value[:A]) / A))

ind = value.index(value[A - 1])
x = value.count(value[A - 1])
q = A - ind
if value[0] != value[A - 1]:
    u = 1
    d = 1
    for i in range(x, x - q, -1):
        u *= i
    for i in range(q, 0, -1):
        d *= i
    print(u // d)
else:
    p = min(B - ind, x)
    ans = 1
    for j in range(q, p + 1):
        u = 1
        d = 1
        for i in range(x, x - j, -1):
            u *= i
        for i in range(j, 0, -1):
            d *= i
        ans += u // d
    print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
value = sorted(list(map(int, input().split())), reverse=True)
print('{:.6f}'.format(sum(value[:A]) / A))

ind = value.index(value[A - 1])
x = value.count(value[A - 1])
q = A - ind
if value[0] != value[A - 1]:
    u = 1
    d = 1
    for i in range(x, x - q, -1):
        u *= i
    for i in range(q, 0, -1):
        d *= i
    print(u // d)
else:
    p = min(B - ind, x)
    ans = 1
    for j in range(q, x):
        u = 1
        d = 1
        for i in range(x, x - j, -1):
            u *= i
        for i in range(j, 0, -1):
            d *= i
        ans += u // d
    print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
value = sorted(list(map(int, input().split())), reverse=True)
print('{:.6f}'.format(sum(value[:A]) / A))

ind = value.index(value[A - 1])
x = value.count(value[A - 1])
q = A - ind
if value[0] != value[A - 1]:
    u = 1
    d = 1
    for i in range(x, x - q, -1):
        u *= i
    for i in range(q, 0, -1):
        d *= i
    print(u // d)
else:
    p = min(B - ind, x)
    ans = 1
    for j in range(q, x):
        u = 1
        d = 1
        for i in range(x, p - j, -1):
            u *= i
        for i in range(j, 0, -1):
            d *= i
        ans += u // d
    print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
value = sorted(list(map(int, input().split())), reverse=True)
print('{:.6f}'.format(sum(value[:A]) / A))

ind = value.index(value[A - 1])
q = A - ind
p = min(B - ind, value.count(value[A - 1]))
ans = 1
for j in range(q, p):
    u = 1
    d = 1
    for i in range(p, p - j, -1):
        u *= i
    for i in range(j, 0, -1):
        d *= i
    ans += u // d
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
from collections import Counter
from decimal import Decimal
from statistics import mean
def combination(a,b):
    if a < b:
        a, b = b, a
    comb = 1
    for i in range(b):
        comb *= a-i
    comb //= factorial(b)
    return comb

N, A, B = map( int, input().split())
V = sorted([int(x) for x in input().split()], reverse=True)
#V = sorted(list( map( int, input().split())), reverse = True)
#print( sum(list( map(Decimal, V[:A])))/Decimal(A))
S = V[:A]
print( mean(S))

CV = Counter(V)
ans = 0
K = CV[ max(V)]
if A <= K:
    for i in range(A, min(K, B)+1):
        ans += combination(K, i)
else:
    cnt = A
    for x in CV:
        if cnt <= CV[x]:
            ans += combination(CV[x],cnt)
            break
        else:
            cnt -= CV[x]
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial

from decimal import Decimal
from statistics import mean
def combination(a,b):
    if a < b:
        a, b = b, a
    comb = 1
    for i in range(b):
        comb *= a-i
    comb //= factorial(b)
    return comb

N, A, B = map( int, input().split())
V = sorted(list( map( int, input().split())), reverse = True)
#print( sum(list( map(Decimal, V[:A])))/Decimal(A))
S = V[:A]
print( mean(S))
from collections import Counter
CV = Counter(V)
ans = 0
K = CV[ max(V)]
if A <= K:
    for i in range(A, min(K, B)+1):
        ans += combination(K, i)
else:
    cnt = A
    for x in CV:
        if cnt <= CV[x]:
            ans += combination(CV[x],cnt)
            break
        else:
            cnt -= CV[x]
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
from collections import Counter
from decimal import Decimal
from statistics import mean
def combination(a,b):
    if a < b:
        a, b = b, a
    comb = 1
    for i in range(b):
        comb *= a-i
    comb //= factorial(b)
    return comb

N, A, B = map( int, input().split())
V = sorted(list( map( int, input().split())), reverse = True)
#print( sum(list( map(Decimal, V[:A])))/Decimal(A))
S = V[:A]
print( mean(S))
CV = Counter(V)
ans = 0
K = CV[ max(V)]
if A <= K:
    for i in range(A, min(K, B)+1):
        ans += combination(K, i)
else:
    cnt = A
    for x in CV:
        if cnt <= CV[x]:
            ans += combination(CV[x],cnt)
            break
        else:
            cnt -= CV[x]
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
from collections import Counter
from decimal import Decimal
def combination(a,b):
    if a < b:
        a, b = b, a
    comb = 1
    for i in range(b):
        comb *= a-i
    comb //= factorial(b)
    return comb

N, A, B = map( int, input().split())
V = sorted(list( map( int, input().split())), reverse = True)
print( Decimal(sum(V[:A]))/Decimal(A))
CV = Counter(V)
ans = 0
K = CV[ max(V)]
if A <= K:
    for i in range(A, min(K, B)+1):
        ans += combination(K, i)
else:
    cnt = A
    for x in CV:
        if cnt <= CV[x]:
            ans += combination(CV[x],cnt)
            break
        else:
            cnt -= CV[x]
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
from collections import Counter
def combination(a,b):
    if a < b:
        a, b = b, a
    comb = 1
    for i in range(b):
        comb *= a-i
    comb //= factorial(b)
    return comb

N, A, B = map( int, input().split())
V = list( map( int, input().split()))
V.sort( reverse = True)
print( sum(V[:A])/A)
CV = Counter(V)
ans = 0
K = CV[ max(V)]
if A <= K:
    for i in range(A, min(K, B)+1):
        ans += combination(K, i)
else:
    cnt = A
    for x in CV:
        if cnt <= CV[x]:
            ans += combination(CV[x],cnt)
            break
        else:
            cnt -= CV[x]
print(ans)

Submission status: Wrong Answer

Solution code:
f = lambda: list(map(int,input().split()))

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

n,a,b = f()
v = f()
v.sort()
print(sum(v[-a:])/a)
import bisect
l1 = n-a-bisect.bisect_left(v, v[-a])
m = min(b-a, l1)
l2 = bisect.bisect(v, v[-a])-n+a

ans = 0
for i in range(m+1):
    ans += nCb(m+l2,l2+i)
print(int(ans))

Submission status: Wrong Answer

Solution code:
f = lambda: list(map(int,input().split()))

n,a,b = f()
v = f()
v.sort()
print(sum(v[-a:])/a)
import bisect, scipy.misc
l1 = n-a-bisect.bisect_left(v, v[-a])
m = min(b-a, l1)
l2 = bisect.bisect(v, v[-a])-n+a

ans = 0
for i in range(m+1):
    ans += scipy.misc.comb(m+l2,l2+i)
print(int(ans))

Submission status: Wrong Answer

Solution code:
f = lambda: list(map(int,input().split()))

n,a,b = f()
v = f()
v.sort()
print(sum(v[-a:])/a)
import bisect, scipy.misc
l1 = n-a-bisect.bisect_left(v, v[-a])
m = min(b-a, l1)
l2 = bisect.bisect(v, v[-a])-n+a

ans = 0
for i in range(m+1):
    ans += scipy.misc.comb(m+l2,l2+i)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        
# 二項係数
def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if not (0<=r and r<=n):
        return 0
    
    return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod

from itertools import accumulate
from collections import Counter

n,a,b = li()
v = li()

v.sort(reverse=True)
v_cum = list(accumulate(v))

ans_cand = []

# 貪欲に最大値を選ぶ
for i in range(a,b+1):
    ans_cand.append(v_cum[i-1] / i)
    
ans = max(ans_cand)
opt_i = a + ans_cand.index(ans) - 1

cnt_v = Counter(v)
opt_set = v[:opt_i+1]

# 貪欲最大が何通りできるか考える
MOD = 46116646144580591
inv = inv_mod(n, MOD)
fac = fact(n, MOD)
facInv = fact_inv(n,inv, MOD)

pat = 0

if v[0] == v[opt_i]:
    for i in range(1, cnt_v[v[0]] + 1):
        pat += nCr(cnt_v[v[0]], i, MOD, fac, facInv)

else:
    cnt_opt = Counter(opt_set)
    pat = nCr(cnt_v[v[opt_i]], cnt_opt[v[opt_i]], MOD, fac, facInv)


        
print(ans)
print(pat)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep  2 17:29:52 2018
ABC057D
@author: maezawa
"""
import math

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

vave = 0
mi = 0
for i in range(a, b+1):
    vsumi = sum(v[:i])
    vavei = vsumi/(i)
    if vave <= vavei:
        vave = vavei
        ci = v.count(v[i-1])
        cin = v[:i].count(v[i-1])
        m = math.factorial(ci)/math.factorial(cin)/math.factorial(ci-cin)
        mi += int(m)

print(vave)
print(mi)

Submission status: Wrong Answer

Solution code:
import math
n,a,b =map(int,input().split())
v = list(map(int,input().split()))
v = sorted(v,key=lambda x:-x)
need = v[:a]
ti = min(need)
no = need.count(ti)
try:
  ona = v[a:].count(ti)
except:
  ona = 0
if ona == 0:
  print(sum(need)/a)
  print(1)
elif no == a:
  ans = 0
  for i in range(b+1-a):
    if ona == -1:
      break
    ans += math.factorial(ona+no)/math.factorial(ona)/math.factorial(no)
    ona -= 1
    no += 1
  print(sum(need)/a)
  print(int(ans))
else:
  print(sum(need)/a)
  print(math.factorial(ona+no)/math.factorial(ona)/math.factorial(no))

Submission status: Wrong Answer

Solution code:
import math
n,a,b =map(int,input().split())
v = list(map(int,input().split()))
v = sorted(v,key=lambda x:-x)
need = v[:a]
ti = min(need)
no = need.count(ti)
try:
  ona = v[a:].count(ti)
except:
  ona = 0
if ona == 0:
  print(sum(need)/a)
  print(1)
else:
  ans = 0
  for i in range(b-a):
    if ona == 0:
      break
    ans += math.factorial(ona+no)/math.factorial(ona)/math.factorial(no)
    ona -= 1
    no += 1
  if (v.count(ti) == n and b == n):
    ans += 1
  print(sum(need)/a)
  print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter

def mycombinations(n, r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n - r)

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

v = sorted(v, reverse=True)

mean_v = [sum(v[:i + 1]) / (i + 1) for i in range(n)]
max_mean_v = mean_v[a - 1]

if v[0] != v[-1]:
    cnt_v = Counter(v)
    cnt_mv = Counter(v[:a])
    cnt = 1
    for i in range(a):
        cnt *= mycombinations(cnt_v[v[i]], cnt_mv[v[i]])
else:
    cnt = 0
    for i in range(n):
        cnt += mycombinations(n, i + 1)

max_mean_v = "{0:.6f}".format(max_mean_v)
cnt = int(cnt)
print(max_mean_v)
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter

def mycombinations(n, r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n - r)

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

v = sorted(v, reverse=True)

mean_v = [sum(v[:i + 1]) / (i + 1) for i in range(n)]
max_mean_v = mean_v[a - 1]

if v[0] != v[-1]:
    cnt_v = Counter(v)
    cnt_mv = Counter(v[:a])
    cnt = 1
    for i in range(a):
        cnt *= mycombinations(cnt_v[v[i]], cnt_mv[v[i]])
else:
    cnt = 0
    for i in range(n):
        cnt += mycombinations(n, i + 1)

max_mean_v = "{0:.6f}".format(max_mean_v)
print(max_mean_v)
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter

def mycombinations(n, r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n - r)

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

v = sorted(v, reverse=True)

mean_v = [sum(v[:i + 1]) / (i + 1) for i in range(n)]
max_mean_v = mean_v[a - 1]

if v[0] != v[-1]:
    cnt_v = Counter(v)
    cnt_mv = Counter(v[:a])
    cnt = 1
    for i in range(a):
        cnt *= mycombinations(cnt_v[v[i]], cnt_mv[v[i]])
else:
    cnt = 0
    for i in range(n):
        cnt += mycombinations(n, i + 1)

print(max_mean_v)
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, V):
    V.sort(reverse=True)
    mean = sum(V[:A])/A

    print(mean)

    if A == N:
        return 1

    c = V[:A].count(V[A-1])
    d = V[A:].count(V[A-1])

    if d == 0:
        return 1
        
    @lru_cache(maxsize=None)
    def comb2(n, r):
        if n < 0 or r < 0 or n < r:
            return 0
        elif n == 0 or r == 0:
            return 1
        return comb2(n-1, r-1)+comb2(n-1, r)

    if V[0] == V[A-1]:
        return sum([comb2(c+d, i) for i in range(1, c+1)])

    return comb2(c+d, c)


def main():
    N, A, B = read_int_n()
    V = read_int_n()

    print(slv(N, A, B, V))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, V):
    V.sort(reverse=True)
    mean = sum(V[:A])/A

    print(mean)

    if A == N:
        return 1

    c = V[:A].count(V[A-1])
    d = V[A:].count(V[A-1])

    if d == 0:
        return 1

    print(c, d)

    @lru_cache(maxsize=None)
    def comb2(n, r):
        if n < 0 or r < 0 or n < r:
            return 0
        elif n == 0 or r == 0:
            return 1
        return comb2(n-1, r-1)+comb2(n-1, r)

    if V[0] == V[A-1]:
        return sum([comb2(c+d, i) for i in range(1, c+1)])

    return comb2(c+d, c)


def main():
    N, A, B = read_int_n()
    V = read_int_n()

    print(slv(N, A, B, V))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, V):
    V.sort(reverse=True)
    mean = sum(V[:A])/A

    print(mean)

    if A == N:
        return 1

    c = 0
    for i in range(A, N):
        if V[i] == V[i-1]:
            c += 1
        else:
            break

    if c == 0:
        return 1

    d = 1
    for i in range(A-1, -1, -1):
        if i > 1 and V[i] == V[i-1]:
            d += 1
        else:
            break

    @lru_cache(maxsize=None)
    def comb2(n, r):
        if n < 0 or r < 0 or n < r:
            return 0
        elif n == 0 or r == 0:
            return 1
        return comb2(n-1, r-1)+comb2(n-1, r)

    if V[0] == V[A-1]:
        return sum([comb2(c+d, i) for i in range(1, c+1)])

    return comb2(c+d, c)


def main():
    N, A, B = read_int_n()
    V = read_int_n()

    print(slv(N, A, B, V))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, V):
    V.sort(reverse=True)
    mean = sum(V[:A])/A

    print(mean)

    if A == N:
        return 1

    c = 0
    for i in range(A, N):
        if V[i] == V[i-1]:
            c += 1
        else:
            break

    if c == 0:
        return 1

    d = 1
    for i in range(A-1, -1, -1):
        if i > 1 and V[i] == V[i-1]:
            d += 1
        else:
            break

    @lru_cache(maxsize=None)
    def comb2(n, r):
        if n < 0 or r < 0 or n < r:
            return 0
        elif n == 0 or r == 0:
            return 1
        return comb2(n-1, r-1)+comb2(n-1, r)
    return sum([comb2(c+d, i) for i in range(1, c+1)])


def main():
    N, A, B = read_int_n()
    V = read_int_n()

    print(slv(N, A, B, V))


if __name__ == '__main__':
    main()