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:
from scipy.misc import comb
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v = sorted(v,reverse=True)

# (合計, 個数)
max_avg = (sum(v[:A]), A)

t = v[A-1]
num1 = v[:A].count(t)
num2 = v[A:].count(t)

fact = [0]*(N+1)
ifact = [0]*(N+1)
inv = [0]*(N+1)
p=170141183460469231731687303715884105727

def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p
def op(n,k):
    if k<0 or k>n or n<0:
        return 0
    return (fact[n]*ifact[k]*ifact[n-k])%p

combination(N,fact,ifact)


res = int(comb(num1+num2, num1))
if v[0]==v[-1]:
    res = 0
    for i in range(A,B+1):
        res += int(op(N, i))
elif N!=B and v[0] == v[B]:
    res = 0
    for i in range(A, A+num2+1):
        res += int(op(num1+num2,i))
elif N!=A and v[0] == v[A]:
    res = 0
    for i in range(A, min(B, A+num2)+1):
        res += int(op(num1+num2, i))
print(max_avg[0]/max_avg[1])
print(res)

Submission status: Wrong Answer

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

# dp[i] := i個選ぶときの価値の最大値
# dq[i] := i個選ぶときの価値の最大値の個数
dp = [0] * (n + 1)
dq = [0] * (n + 1)

dq[0] = 1

for i in range(n):
    val = v[i]
    # i番目を選ぶとき
    for j in range(n)[::-1]:
        if dp[j + 1] == dp[j] + val:
            dq[j + 1] += dq[j]
        if dp[j + 1] < dp[j] + val:
            dp[j + 1] = dp[j] + val
            dq[j + 1] = 1
        else:
            continue

max_ans = 0
max_cnt = 10 ** 30
for i in range(a, b + 1):
    if max_cnt * dp[i] > max_ans * i:
        max_ans = dp[i]
        max_cnt = i

ans = 0
for i in range(a, b + 1):
    if max_cnt * dp[i] == max_ans * i:
        ans += dq[i]

print(max_ans / max_cnt)
print(ans)

Submission status: Wrong Answer

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

# dp[i] := i個選ぶときの価値の最大値
# dq[i] := i個選ぶときの価値の最大値の個数
dp = [0] * (n + 1)
dq = [0] * (n + 1)

dq[0] = 1

for i in range(n):
    val = v[i]
    # i番目を選ぶとき
    for j in range(n)[::-1]:
        if dp[j + 1] == dp[j] + val:
            dq[j + 1] += dq[j]
        if dp[j + 1] < dp[j] + val:
            dp[j + 1] = dp[j] + val
            dq[j + 1] = 1
        else:
            continue

max_ans = 0
for i in range(a, b + 1):
    max_ans = max(max_ans, dp[i] / i)

ans = 0
for i in range(a, b + 1):
    if max_ans == dp[i] / (i):
        ans += dq[i]

print(max_ans)
print(ans)

Submission status: Wrong Answer

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

# (合計, 個数)
max_avg = (sum(v[:A]), A)

t = v[A-1]
num1 = v[:A].count(t)
num2 = v[A:].count(t)

fact = [0]*(N+1)
ifact = [0]*(N+1)
inv = [0]*(N+1)
p=170141183460469231731687303715884105727

def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p
def op(n,k):
    if k<0 or k>n or n<0:
        return 0
    return (fact[n]*ifact[k]*ifact[n-k])%p

combination(N,fact,ifact)


res = int(comb(num1+num2, num1))
if v[0]==v[-1]:
    res = 0
    for i in range(A,B+1):
        res += int(op(N, i))

print(max_avg[0]/max_avg[1])
print(res)

Submission status: Wrong Answer

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

total = sum(V[:A])

ave = total / A

tmp = V[A - 1]

count = V.count(tmp)

def combination(n, r): #nCrを求める
    if n - r > r:
        r = n - r
    tmp = 1
    for i in range(n - r + 1, n + 1):
        tmp *= i
    for i in range(1, r + 1):
        tmp //= i
    return tmp





if V[0] == V[A - 1]: #上からA個が同じ
    ans = 0
    for i in range(A, min(B, count) + 1):
        ans += combination(count, A)

else: #A個ちょうど取るのがいいとき
    count2 = V[:A].count(tmp)
    ans = combination(count, count2)

print (ave)
print (ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math

def main():
    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    v.sort(reverse=True)
    c = Counter(v)
    
    base = 0
    num = []
    for i in range(min(A, B)):
        base += v[i]
        if not v[i] in num:
            num.append(v[i])
    ans = float(base) / float(min(A, B))
    te = []
    for i in range(len(num)):
        te.append(c[v[i]])
        
    exa = 1
    if(len(te) == 1 and te[0] > 1):
        exa = 0
        for i in range(A, min(te[0]+1, B+1)):
            exa += math.factorial(te[0])//(math.factorial(te[0]-i)*math.factorial(i))
    else:
        for i in range(len(te)):
            if(te[i] == 1):
                continue
            exa *= math.factorial(te[i])//(math.factorial(te[i]-A+1)*math.factorial(A-1))
            
    print(ans)
    print(exa)
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math

def main():
    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    v.sort(reverse=True)
    c = Counter(v)
    
    base = 0
    num = []
    for i in range(min(A, B)):
        base += v[i]
        num.append(c[v[i]])
    ans = float(base) / float(min(A, B))
    
    exa = 1
    if(len(num) == 1):
        exa = 0
        for i in range(1, num[0]+1):
            exa += math.factorial(N)//(math.factorial(N-i)*math.factorial(i))
    else:
        for i in range(len(num)):
            exa *= num[i]
    print(ans)
    print(exa)
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math

def main():
    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    v.sort(reverse=True)
    c = Counter(v)
    
    base = 0
    num = []
    for i in range(min(A, B)):
        base += v[i]
        num.append(c[v[i]])
    ans = float(base) / float(min(A, B))
    

    exa = 1
    if(len(num) == 1):
        for i in range(1, num[0]):
            exa += math.factorial(N)//(math.factorial(N-i)*math.factorial(i))
    else:
        for i in range(len(num)):
            exa *= num[i]
    print(ans)
    print(exa)
main()

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# ソートして上位A個を使うと最大
# 場合の数は，vの最大値がA個以上あるかで場合分け

N,A,B = LI()
v = LI()

def linear_nCk(n,k):
    a = [1]*(k+1)
    for i in range(1,k+1):
        a[i] = a[i-1]*(n-k+i)//i
    return a[-1]

v.sort(reverse=True)

d = defaultdict(int)
use = defaultdict(int)

for i in range(N):
    d[v[i]] += 1
    if i < A:
        use[v[i]] += 1

if v[0] == v[A-1]:
    num = d[v[0]]
    ans = 0
    for i in range(A,num+1):
        ans += linear_nCk(num,i)
    print(v[0])
    print(ans)
else:
    max_val = 0
    ans = 1
    for k,v in use.items():
        ans *= linear_nCk(d[k],v)
        max_val += k*v
    print(max_val/A)
    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)
ans = sum(v[:A]) / A
print(ans)
count1 = Counter(v)
count2 = Counter(v[:A])

if len(set(v[:A])) == 1:
    cnt = 0
    for i in range(A, min(B+1, count1[v[0]]+1)):
        cnt += comb(count1[v[0]], i)
    print(int(cnt))
else:
    key = v[A-1]
    print(int(comb(count1[key], count2[key])))

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)
ans = sum(v[:A]) / A
print(ans)
count1 = Counter(v)
count2 = Counter(v[:A])

if len(set(v[:A])) == 1:
    cnt = 0
    for i in range(A, count1[v[0]]+1):
        cnt += comb(count1[v[0]], i)
    print(int(cnt))
else:
    key = v[A-1]
    print(int(comb(count1[key], count2[key])))

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)
ans = sum(v[:A]) / A
print(ans)
count1 = Counter(v)
count2 = Counter(v[:A])

if len(set(v[:A])) == 1:
    cnt = 0
    for i in range(A, count1[v[0]]+1):
        cnt += comb(count1[v[0]], i)
    print(cnt)
else:
    key = v[A-1]
    print(comb(count1[key], count2[key]))

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)
print(sum(V[:A])/A)
t = V[A-1]
t1 = 0
t2 = 0
for i in range(len(V)):
    if V[i] == t:
        if i < A:
            t2 += 1
        t1 += 1
t1 = min(t1, t2+B-A)


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


res = 0
for i in range(t2, t1+1):
    res += ncr(t1, i)
print(res)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)
NV = V[:A-1]
V = V[A-1:]
tes = 0
for i in range(len(V)):
    if V[i] == V[0]:
        tes += 1

print((sum(NV)+V[0])/A)
print(2**min(tes, B-A+1) - 1)

Submission status: Wrong Answer

Solution code:
from math import factorial
def comb(n,r):
  if n-r<0:
    return 0
  return factorial(n)//(factorial(r)*factorial(n-r))
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
mod=10**9+7
v.sort(reverse=True)
x=v[a-1]
cnt=0
s=0
for i in range(n):
  if x==v[i]:
    cnt+=1
  if x<v[i]:
    s=i
ans=0
for i in range(max(1,s-a+1),b-s+1):
  ans+=comb(cnt,i)
print(sum(v[:a])/a)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
def comb(n,r):
  if n-r<0:
    return 0
  return factorial(n)//(factorial(r)*factorial(n-r))
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
mod=10**9+7
v.sort(reverse=True)
x=v[a-1]
cnt=0
s=0
for i in range(n):
  if x==v[i]:
    cnt+=1
  if x<v[i]:
    s=i
ans=0
for i in range(max(1,s-a+1),b-s):
  ans+=comb(cnt,i)
print(sum(v[:a])/a)
print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

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

ans = 0
for i in range(A,B+1):
    ans = max(sum(v[:i])/i, ans)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
        
def combination(n, k):
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)
            
import collections  
    
n,a,b = map(int,input().split())

t = list(map(int,input().split()))

c = collections.Counter(t)

c = sorted(c.items(), key=lambda x:-x[0])

memo = 0

for k,i in enumerate(c):
    #print(k,i[0],i[1])
    memo += i[1]
    if a<=memo:
        ans = 0
        memo2=0
        for j in range(k+1):
            if j != k:
                memo2 += c[j][1]
                ans += c[j][0]*c[j][1]
            else:
                ans += c[j][0]*(a-memo2)
        print(ans/a)
        break
if c[0][1] <= a:
    
    print(combination(c[j][1],a-memo2))
else:
    ans1=0
    for l in range(a,c[0][1]+1):
        ans1 += combination(c[j][1],l)
    print(ans1)

Submission status: Wrong Answer

Solution code:
import math
        
def combination(n, k):
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)
            
import collections  
    
n,a,b = map(int,input().split())

t = list(map(int,input().split()))

c = collections.Counter(t)

c = sorted(c.items(), key=lambda x:-x[0])

memo = 0

for k,i in enumerate(c):
    #print(k,i[0],i[1])
    memo += i[1]
    if a<=memo:
        ans = 0
        memo2=0
        for j in range(k+1):
            if j != k:
                memo2 += c[j][1]
                ans += c[j][0]*c[j][1]
            else:
                ans += c[j][0]*(a-memo2)
        print(ans/a)
        break
if j != 0 or j == 0 and a==c[0][1]:
    
    print(combination(c[j][1],a-memo2))
else:
    ans1=0
    for l in range(a,c[j][1]+1):
        ans1 += combination(c[j][1],l)
    print(ans1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


def create_factorial(n):
    """
    階乗を事前計算した配列を作成します。
    :param n: [0, n]の配列を作成します
    """
    f = list()
    for i in range(n + 1):
        if i in [0, 1]:
            f.append(1)
        else:
            f.append(f[i - 1] * i)
    return f

N, A, B = MI()
V = sorted(LMI(), reverse=True)

# s = [(v0, n), (v1, m), (v2, l)...]
s = []
cur = V[0]
cnt = 0
for v in V:
    if v != cur:
        s.append((cur, cnt))
        cur = v
        cnt = 1
    else:
        cnt += 1
s.append((cur, cnt))


f = create_factorial(51)

def comb(n, r):
    return f[n] // f[n - r] * f[r]

a = list()
for i in range(A, B + 1):
    selected = 0
    sval = 0
    for v, n in s:
        if selected + n < i:
            selected += n
            sval += v * n
        else:
            sval += v * (i - selected)
            val = sval / i
            c = comb(n, i - selected)
            a.append((val, c))
            break
a.sort(reverse=True)

ans = a[0][0]
cans = 0
for val, c in a:
    if val == ans:
        cans += c
print(ans)
print(cans)

Submission status: Wrong Answer

Solution code:
def ncr(n,r):
    g = 1
    for i in range(1,r+1):
        g*=(n-r+i)
        g//=i
    return g
n,a,b= map(int,input().split())
nv = sorted(list(map(int,input().split())),reverse=True)
maxav = sum(nv[:a])/a
ndica = {}
ndicfull = {}
conti = 0
fnv=nv[0]
for i,temp in enumerate(nv):
    if i<a:ndica[temp] = ndica.get(temp,0) + 1
    ndicfull[temp] = ndicfull.get(temp,0) + 1
    if temp==fnv:conti=i+1
if fnv == nv[a-1]:
    subb = min(conti,b)
    g=0
    for t in range(a,subb+1):g+=ncr(conti,t)
    print(g)
else:
    if ndicfull[nv[a-1]]==1:print(1)
    else:print(ncr(ndicfull[nv[a-1]],ndica[nv[a-1]]))

Submission status: Wrong Answer

Solution code:
from math import factorial as f
from decimal import *

def comb(n, r):
  return f(n) // (f(r) * f(n-r))

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

v.sort(reverse=True)

print(Decimal(sum(v[:a]))/Decimal(a))

ans = 0
if len(set(v)) == 1:
  for i in range(a, b+1):
    ans += comb(n, i)
else:
  c = v[a-1]
  cnt1 = 0
  cnt2 = 0
  for i, vi in enumerate(v):
    if vi != c:
      continue
    if i < a:
      cnt1 += 1
    cnt2 += 1
  ans = comb(cnt2, cnt1)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial as f

def comb(n, r):
  return f(n) // (f(r) * f(n-r))

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

v.sort(reverse=True)

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

ans = 0
if len(set(v)) == 1:
  for i in range(a, b+1):
    ans += comb(n, i)
else:
  c = v[a-1]
  cnt1 = 0
  cnt2 = 0
  for i, vi in enumerate(v):
    if vi != c:
      continue
    if i < a:
      cnt1 += 1
    cnt2 += 1
  ans = comb(cnt2, cnt1)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial as f

def comb(n, r):
  return f(n) // f(r) // f(n-r)

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

v.sort(reverse=True)

ans = 0

for vi in reversed(v[:a]):
  ans += vi / a
print(ans)

ans = 0
if len(set(v)) == 1:
  for i in range(a, b+1):
    ans += comb(n, i)
else:
  c = v[a-1]
  cnt1 = 0
  cnt2 = 0
  for i, vi in enumerate(v):
    if vi != c:
      continue
    if i < a:
      cnt1 += 1
    cnt2 += 1
  ans = comb(cnt2, cnt1)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial as f

def comb(n, r):
  return f(n) // f(r) // f(n-r)

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

v.sort(reverse=True)

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

ans = 0
if len(set(v)) == 1:
  for i in range(a, b+1):
    ans += comb(n, i)
else:
  c = v[a-1]
  cnt1 = 0
  cnt2 = 0
  for i, vi in enumerate(v):
    if vi != c:
      continue
    if i < a:
      cnt1 += 1
    cnt2 += 1
  ans = comb(cnt2, cnt1)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial as f

def comb(n, r):
  return f(n) // f(r) // f(n-r)

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

v.sort(reverse=True)

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

ans = 0
if len(set(v)) == 1:
  for i in range(a, b+1):
    ans += comb(n, i)
else:
  c = v[a-1]
  cnt1 = 0
  cnt2 = 0
  for i, vi in enumerate(v):
    if i < a:
      cnt1 += 1
    cnt2 += 1
  ans = comb(cnt2, cnt1)

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split( ))
v = list(map(int, input().split( )))
v.sort(reverse = True)
#n,a,b = 50,1,50
#v = [1 for i in range(50)]
ath = v[a-1]
v.append(0)#番兵

right = a-1
while v[right+1]==v[a-1]:
    right += 1

left = a-1
while v[left-1]==v[a-1]:
    left -= 1
## //だと整数
ave = sum(v[:a])/a
print(ave)
def chs(x,y):#modとらない
    res = 1
    for i in range(x,x-y,-1):
        res *= i
    for i in range(1,y+1):
        res //= i
    return res

x = right -left + 1
ans = 0
if v[0] == v[a-1]:##この場合以外はv[a-1]の値は一つ,ave==v[a-1]だとaveは誤差ありの実数
    #nが小さいので愚直
    for i in range(a-left,min(b,right)-left+1):
        ans += chs(x,i)
    print(ans)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split( ))
v = list(map(int, input().split( )))
v.sort(reverse = True)
#n,a,b = 50,1,50
#v = [1 for i in range(50)]
ath = v[a-1]
v.append(0)#番兵

right = a-1
while v[right+1]==v[a-1]:
    right += 1

left = a-1
while v[left-1]==v[a-1]:
    left -= 1
## //だと整数
ave = sum(v[:a])/a
print(ave)
def chs(x,y):#modとらない
    res = 1
    for i in range(x,x-y,-1):
        res *= i
    for i in range(1,y+1):
        res //= i
    return res

x = right -left + 1
ans = 0
if v[0] == v[a-1]:##この場合以外はv[a-1]の値は一つ,ave==v[a-1]だとaveは誤差ありの実数
    #nが小さいので愚直
    for i in range(a-left,b-left+1):
        ans += chs(x,i)
    print(ans)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
import math
N,A,B=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)
dic={}
for i in range(N):
  v=a[i]
  if v not in dic.keys():
    dic[v]=1
  else:
    dic[v]+=1
tmp=0
num_used={}
m=10**18
for i in range(A):
  v=a[i]
  m=min(m,v)
  tmp+=v
  if v not in num_used.keys():
    num_used[v]=1
  else:
    num_used[v]+=1
max_ave=tmp/A
print(max_ave)
if num_used[m]==dic[m]:
  print(1)
else:
  x=dic[m]
  y=num_used[m]
  cnt=0
  for i in range(y,min(x,B-A+y)+1):
    cnt+=math.factorial(x)//math.factorial(i)//math.factorial(x-i)
  print(cnt)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split( ))
v = list(map(int, input().split( )))
v.sort(reverse = True)
#n,a,b = 50,1,50
#v = [1 for i in range(50)]
ath = v[a-1]
v.append(0)#番兵

right = a-1
while v[right+1]==v[a-1]:
    right += 1

left = a-1
while v[left-1]==v[a-1]:
    left += 1
#print(right,left)
ave = sum(v[:a])//a
print(ave)

def chs(x,y):#modとらない
    res = 1
    for i in range(x,x-y,-1):
        res *= i
    for i in range(1,y+1):
        res //= i
    return res

#この辺の添え字の詰め方がわからん
x = right -left +1
#y = b-left
#nが小さいので
#print(x,y)
ans = 0
for i in range(a-left,b-left+1):
    ans += chs(x,i)
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split( ))
v = list(map(int, input().split( )))
v.sort(reverse = True)
#n,a,b = 50,1,50
#v = [1 for i in range(50)]
ath = v[a-1]
v.append(0)#番兵

right = a-1
while v[right+1]==v[a-1]:
    right += 1

left = a-1
while v[left-1]==v[a-1]:
    left += 1
#print(right,left)
ave = sum(v[:a])//a
print(ave)

def chs(x,y):#modとらない
    res = 1
    for i in range(x,x-y,-1):
        res *= i
    for i in range(1,y+1):
        res //= i
    return res

#この辺の添え字の詰め方がわからん
x = right -left +1
y = b-left
#nが小さいので
#print(x,y)
ans = 0
for i in range(1,y):
    ans += chs(x,i)
print(ans)

Submission status: Wrong Answer

Solution code:
N, A,B,*V = map(int,open(0).read().split())
V = sorted(V)[::-1]
ans1 = sum(V[:A])/A
print(ans1)
f = [1] *51
for i in range(1,51):
  f[i] = f[i - 1] * i
def comb(n,r):
  return f[n]//f[r]//f[n-r]
ans2 = 0
if V[0] != V[A-1]:
  ans2 = comb(V.count(V[A-1]),V[:A].count(V[A-1]))
elif V[A-1] != V[A] or A == B:
  ans2 = 1
else:
  for i in range(1,V[A:B].count(V[A-1])):
    ans2 += comb(V.count(V[A-1]),i)
print(ans2)

Submission status: Wrong Answer

Solution code:
from math  import factorial as fact
N, A,B,*V = map(int,open(0).read().split())
V = sorted(V)[::-1]
ans1 = sum(V[:A])/A
print(ans1)
f = [1] *51
for i in range(1,51):
  f[i] = f[i - 1] * i
def comb(n,r):
  return f[n]//f[r]//f[n-r]
ans2 = 0
if V[0] != V[A]:
  ans2 = comb(V.count(V[A]),V[:A].count(V[A]))
elif V[A] != V[A+1] or A == B:
  ans2 = 1
else:
  for i in range(1,V[A:B].count(V[A])):
    ans2 += comb(V.count(V[A]),i)
print(ans2)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque, Counter

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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()

fac = [-1] * (10**2+1)

fac[0] = fac[1] = 1

def initNCM(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i

def NCM(n, r):
    return fac[n] / (fac[r] * fac[n-r])

initNCM(100)

def main():
    N, A, B = LI()
    v = sorted(LI())[::-1]
    cnt = Counter(v)
    selected = v[:A]
    print(sum(selected)/A)
    ans = 1
    used = 0
    for x in list(set(selected)):
        used += cnt[x]
    used -= cnt[selected[-1]]
    ans = 0
    if len(selected) > 1:
        use_last = A - used
        ans += NCM(cnt[selected[-1]], use_last)
    else:
        for use_last in range(1, N+1):
            if not A <= used + use_last <= B:
                continue
            if use_last > cnt[selected[-1]]:
                continue
            ans += NCM(cnt[selected[-1]], use_last)
    print(int(ans))

main()

Submission status: Wrong Answer

Solution code:
from math  import factorial as fact
N, A,B,*List = map(int,open(0).read().split())

List = sorted(List)[::-1]
ans = sum(List[:A])/A
total = List.count(List[A])
candidate = List[:A].count(List[A])

print(ans)

if ans == sum(List)/len(List):
  ans2 = 0
  for i in range(A,B+1):
    ans2 += fact(N)//(fact(N - i)*fact(i))
  print(ans2)
  exit()

ans2 = fact(total)//(fact(total - candidate)*fact(candidate))
print(ans2)

Submission status: Wrong Answer

Solution code:
from math  import factorial as fact
N, A,B,*List = map(int,open(0).read().split())
List = sorted(List)[::-1]
ans = sum(List[:A])/A
total = List.count(List[A])
candidate = List[:A].count(List[A])
ans2 = fact(total)//(fact(total - candidate)*fact(candidate))
print(ans)
print(ans2)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
v=[int(x)for x in input().split()]
v.sort(reverse=True)
a=sum(v[:A])/A
m=min(v[:A])
k=v.count(m)
l=v.index(m)
ans=0
import math
for i in range(A,B+1):
    if i==A:
        ans+=(math.factorial(k)/math.factorial(i-l))/math.factorial(k-i+l)
    else:
        if k-i+l>=0 and a==m:
            ans+=(math.factorial(k)//math.factorial(i-l))//math.factorial(k-i+l)
        else:
            break
            
            
print("{:.1f}".format(a))
print(int(ans))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
v=[int(x)for x in input().split()]
v.sort(reverse=True)
a=sum(v[:A])/A
m=min(v[:A])
k=v.count(m)
l=v.index(m)
ans=0
import math
for i in range(A,B+1):
    if i==A:
        ans+=(math.factorial(k)/math.factorial(i-l))/math.factorial(k-i+l)
    else:
        if k-i+l>=0 and a==m:
            ans+=(math.factorial(k)//math.factorial(i-l))//math.factorial(k-i+l)
        else:
            break
            
            
print("{:.6f}".format(a))
print(int(ans))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
v=[int(x)for x in input().split()]
v.sort(reverse=True)
a=sum(v[:A])/A
m=min(v[:A])
k=v.count(m)
l=v.index(m)
ans=0
print(m)
print(v)
print(k)
print(l)
import math
for i in range(A,B+1):
    if i==A:
        ans+=(math.factorial(k)/math.factorial(i-l))/math.factorial(k-i+l)
    else:
        if k-i+l>=0 and a==m:
            ans+=(math.factorial(k)//math.factorial(i-l))//math.factorial(k-i+l)
        else:
            break
            
            
print("{:.6f}".format(a))
print(int(ans))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
v=[int(x)for x in input().split()]
v.sort(reverse=True)
a=sum(v[:A])/A
m=min(v[:A])
k=v.count(m)
l=v.index(m)
ans=0
import math
for i in range(A,B+1):
    if i==A:
        ans+=(math.factorial(k)/math.factorial(i-l))/math.factorial(k-i+l)
    else:
        if k-i+l>=0 and a==m:
            ans+=(math.factorial(k)/math.factorial(i-l))/math.factorial(k-i+l)
        else:
            break
            
            
print("{:.6f}".format(a))
print(int(ans))

Submission status: Wrong Answer

Solution code:
from collections import Counter


def binomial_coefficient(n, r):
    res = 1
    for i in range(r):
        res *= (n - i)
        res //= (i + 1)
    return res


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

C = Counter(V)

ave = sum(V[:A]) / A
num = V[A - 1]
Nnums = C[num]

if num == V[0]:
    Nnums = min(B, Nnums)
    cnt = 0
    for i in range(A, Nnums + 1):
        cnt += binomial_coefficient(Nnums, i)
else:
    for k, v in C.items():
        if k > num:
            A -= v
    cnt = binomial_coefficient(Nnums, A)

print(ave)
print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def binomial_coefficient(n, r):
    res = 1
    for i in range(r):
        res *= (n - i)
        res //= (i + 1)
    return res


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

C = Counter(V)
C = sorted(list(C.items()))

ave = sum(V[:A]) / A
num = V[A - 1]

if num == C[-1][0]:
    cnt = 0
    B = min(B, C[-1][1])
    for i in range(A, B + 1):
        cnt += binomial_coefficient(B, i)
else:
    while True:
        k, v = C.pop()
        if num == k:
            break
        A -= v
        B -= v
    cnt = binomial_coefficient(v, A)

print(ave)
print(cnt)

Submission status: Wrong Answer

Solution code:
def comb(n, r):
    ret = 1
    for i in range(1, r + 1):
        ret = ret * (n - i + 1) // i

    return ret


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

v.sort(reverse=True)
ave = sum(v[:a]) / a

if v[0] == v[-1]:
    cnt = 0
    for i in range(a, b + 1):
        cnt += comb(n, i)

else:
    last = v[a-1]
    select = v[:a].count(last)
    sm = v.count(last)
    cnt = comb(sm, select)

print(ave)
print(cnt)

Submission status: Wrong Answer

Solution code:
#mAx average set
n,a,b=map(int,input().split())
lists=list(map(int,input().split()))
lists=sorted(lists)
P=sum(lists[-a:])
print(P/a)
#Bことって総和がminiになっている
from collections import Counter
J=dict(Counter(lists))
K=dict(Counter(lists[-a:]))
import math
ans=1
sums=0
if J[max(lists)]<a:
    for some in K.keys():
        ans*=(math.factorial(J[some])//((math.factorial(K[some]))*math.factorial(J[some]-K[some])))
    print(ans)
elif J[max(lists)]>=a:
    for i in range(a,J[max(lists)]+1):
        sums+=math.factorial(J[max(lists)])//(math.factorial(J[max(lists)]-i)*math.factorial(i))
    print(sums)

Submission status: Wrong Answer

Solution code:
#mAx average set
n,a,b=map(int,input().split())
lists=list(map(int,input().split()))
lists=sorted(lists)
P=sum(lists[-a:])
print(P/a)
#Bことって総和がminiになっている
from collections import Counter
J=dict(Counter(lists))
K=dict(Counter(lists[-a:]))
import math
ans=1
sums=0
if J[max(lists)]<a:
    for some in K.keys():
        ans*=(math.factorial(J[some])//((math.factorial(K[some]))*math.factorial(J[some]-K[some])))
elif J[max(lists)]>=a:
    for i in range(a,J[max(lists)]+1):
        sums+=math.factorial(J[max(lists)])//(math.factorial(J[max(lists)]-i)*math.factorial(i))
    print(sums)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N,A,B = map(int,input().split())
    v = sorted(list(map(int,input().split())),reverse=True)
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
    
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)

    ans = 0
    if v[0] == v[B-1]:
        for i in range(A,B+1):
            ans += fac[B]//(fac[i]*fac[B-i])
        print(v[0])
        print(ans)
    else:
        print(sum(v[:A])/A)
        c = v.count(v[A-1])
        index = v.index(v[A-1])
        use = A-index
        ans += fac[c]//(fac[use]*fac[c-use])
        print(ans)

if __name__ == "__main__":
    main()