s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s343914306 | p03776 | u074220993 | 1597669864 | Python | Python (3.8.2) | py | Runtime Error | 39 | 10964 | 478 | import statistics
import math
N, A, B = map(int, input().split())
v = [int(x) for x in input().split()]
v.sort()
base = v[N-A:]
rem = v[:N-A]
mean_max = statistics.mean(base)
cnb = 0
while mean_max == statistics.mean(base) or not len(rem) == 0:
same = base.count(base[0])
extra = rem.count(base[0])
cnb += math.factorial(same+extra)/math.factorial(same)/math.factorial(extra)
base.append(rem[len(rem)-1])
rem = rem.pop
print(mean_max)
print(math.floor(cnb)) |
s715579051 | p03776 | u074220993 | 1597669770 | Python | Python (3.8.2) | py | Runtime Error | 40 | 10960 | 457 | import statistics
import math
N, A, B = map(int, input().split())
v = [int(x) for x in input().split()]
v.sort()
base = v[N-A:]
rem = v[:N-A]
mean_max = statistics.mean(base)
cnb = 0
while mean_max == statistics.mean(base):
same = base.count(base[0])
extra = rem.count(base[0])
cnb += math.factorial(same+extra)/math.factorial(same)/math.factorial(extra)
base.append(rem[len(rem)-1])
rem = rem.pop
print(mean_max)
print(math.floor(cnb)) |
s984905469 | p03776 | u332657092 | 1597512892 | Python | PyPy3 (7.3.0) | py | Runtime Error | 81 | 74148 | 406 | from math import factorial
n, a, b = map(int, input().split())
V = sorted(map(int, input().split()), reverse=True)
av = sum(V[:a]) / a
print(av)
num = V[a]
m = V.count(num)
k = V[:a].count(num)
#print(m, k, a)
if a != k:
ans = factorial(m) // (factorial(k) * factorial(m - k))
else:
ans = 0
for i in range(a, b+1):
ans += factorial(m) // (factorial(i) * factorial(m - i))
print(ans)
|
s368134842 | p03776 | u699522269 | 1595688908 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8996 | 17 | 4 2 3
10 20 10 10 |
s334330418 | p03776 | u145231176 | 1595603759 | Python | PyPy3 (7.3.0) | py | Runtime Error | 174 | 83748 | 1965 | def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
N, A, B = getNM()
V = sorted(getList(), reverse = True)
print(sum(V[:A]) / A)
dict = defaultdict(int)
for i in range(N):
dict[V[i]] += 1
r = A
n = 0
for i in dict.items():
if r - i[1] >= 0:
r -= i[1]
else:
n = i[1]
break
def cmb_1(n, r):
r = min(n - r, r)
# ไปๅใฏ0ๅใฎไธญใใrๅ้ธใถๆ1ใ่ฟใใใใใใซใใ
if n == 0:
return 1
if r == 0:
return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1, r + 1))
return over // under
ans = 0
if r > 0 and V[0] == V[A - 1]:
for i in range(r, B + 1):
ans += cmb_1(n, i)
else:
ans += cmb_1(n, r)
print(ans) |
s528248525 | p03776 | u145231176 | 1595603080 | Python | PyPy3 (7.3.0) | py | Runtime Error | 195 | 77876 | 2023 | def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
N, A, B = getNM()
V = sorted(getList(), reverse = True)
print(sum(V[:A]) / A)
dict = defaultdict(int)
for i in range(N):
dict[V[i]] += 1
r = A
n = 0
for i in dict.items():
if r - i[1] >= 0:
r -= i[1]
else:
n = i[1]
break
def cmb_1(n, r):
r = min(n - r, r)
# ไปๅใฏ0ๅใฎไธญใใrๅ้ธใถๆ1ใ่ฟใใใใใใซใใ
if n == 0:
return 1
if r == 0:
return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1, r + 1))
return over // under
ans = 0
if r > 0 and V[0] == V[A - 1]:
# nๅใใ r ~ r + (B - A)ๅ้ธใถ้ใ
for i in range(r, r + (B - A) + 1):
ans += cmb_1(n, i)
else:
ans += cmb_1(n, r)
print(ans) |
s245182097 | p03776 | u145231176 | 1595602529 | Python | PyPy3 (7.3.0) | py | Runtime Error | 219 | 83600 | 1915 | def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
N, A, B = getNM()
V = sorted(getList(), reverse = True)
print(sum(V[:A]) / A)
dict = defaultdict(int)
for i in range(N):
dict[V[i]] += 1
r = A
n = 0
for i in dict.items():
if r - i[1] >= 0:
r -= i[1]
else:
n = i[1]
break
def cmb_1(n, r):
r = min(n - r, r)
if r == 0:
return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1, r + 1))
return over // under
ans = 0
if r > 0 and V[0] == V[A - 1]:
# nๅใใ r ~ r + (B - A)ๅ้ธใถ้ใ
for i in range(r, r + (B - A) + 1):
ans += cmb_1(n, i)
else:
ans += cmb_1(n, r)
print(ans) |
s765459887 | p03776 | u054514819 | 1595383547 | Python | PyPy3 (7.3.0) | py | Runtime Error | 91 | 74564 | 637 | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)
N, A, B = mapint()
Vs = list(mapint())
Vs.sort(reverse=True)
from collections import defaultdict, Counter
from scipy.special import comb
count = defaultdict(int)
c = Counter(Vs)
ans = 0
for i in range(A, B+1):
val = sum(Vs[:i])/i
if val>=ans:
ans = val
lowest_cnt = 0
lowest = Vs[i-1]
for j in range(i):
if Vs[j]==lowest:
lowest_cnt += 1
count[int(ans*2)] += comb(c[lowest], lowest_cnt)
print(ans)
print(count[int(ans*2)]) |
s132759142 | p03776 | u617515020 | 1595296340 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9248 | 437 | N,A,B=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
a=v[:A]
b=v[:B]
avg=sum(a)/A
print(avg)
c=[[0]*51 for _ in range(51)]
c[0][0]=1
for i in range(50):
c[i+1][0]=1
c[i+1][i+1]=1
for j in range(i):
c[i+1][j+1]=c[i][j]+c[i][j+1]
if a[0]==a[-1]:
ans=0
x=v.count(a[0])
for i in range(A,B+1):
if i<=x:
ans+=C[x][i]
else:
x=v.count(a[-1])
y=a.count(a[-1])
ans=c[x][y]
print(ans) |
s557485618 | p03776 | u375616706 | 1595125064 | Python | PyPy3 (7.3.0) | py | Runtime Error | 95 | 74476 | 1412 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
signed main() {
int n, a, b;
cin >> n >> a >> b;
double v[n];
map<double, int, greater<double>> mp;
rep (i, 0, n) {
cin >> v[i];
mp[v[i]]++;
}
int cnt = 0;
double sum = 0;
ll ans = 1;
double ave = 0;
for (auto p : mp) {
if (cnt + p.second < a) {
sum += p.second * p.first;
cnt += p.second;
} else if (a <= cnt + p.second) {
if (cnt == 0) {
ans=0;
rep(k,A,min(B,p.second)+1){
ll tmp=1;
rep (i, 1, p.second + 1) tmp *= i;
rep (i, 1, k + 1) tmp /= i;
rep (i, 1, p.second - k + 1) tmp /= i;
ans+=tmp;
}
ave = p.first;
} else {
int cnt2 = a - cnt;
rep (i, 1, p.second + 1) ans *= i;
rep (i, 1, cnt2 + 1) ans /= i;
rep (i, 1, p.second - cnt2 + 1) ans /= i;
ave = (sum + cnt2 * p.first) / a;
}
break;
}
}
cout << fixed << setprecision (15) << ave << "\n" << ans << "\n";
}
|
s133145438 | p03776 | u375616706 | 1595123716 | Python | PyPy3 (7.3.0) | py | Runtime Error | 96 | 74864 | 995 | from collections import Counter
from math import factorial
def comb(n,r):
return factorial(n)//factorial(r)//factorial(n-r)
N,A,B = map(int,input().split())
V=list(map(int,input().split()))
V_C=Counter(V)
max_val=max(V)
CC=V_C[max_val]
if A<=CC<=B:
ans=0
for v in range(A,min(B,CC)+1):
ans+=comb(CC,v)
print(max_val)
print(ans)
exit()
assert 1==2
tmp_sum=0
tmp_num=0
for key in sorted(V_C.keys(),reverse=True):
val = V_C[key]
assert tmp_num<A
#่ฟฝๅ ใใฆใๅคงไธๅคซใชใๅ ใใ(ๅ ใใชใใจAใซ่กใใชใใใๅ ใใชใใจใใใชใ)
#ใใAใซๅฑใใใใซ่ฟฝๅ ใใใฎใ่ฏใ
if A<=tmp_num+val:
rest=A-tmp_num
tmp_num+=rest
tmp_sum+=key*rest
assert tmp_num==A
assert rest<=val
assert rest!=0
print(tmp_sum/tmp_num)
print(comb(val,rest))
exit()
else:
tmp_num+=val
tmp_sum+=key*val
assert tmp_num<A
assert 1==2
|
s590907558 | p03776 | u375616706 | 1595123523 | Python | PyPy3 (7.3.0) | py | Runtime Error | 90 | 74768 | 1135 | from collections import Counter
from math import factorial
from operator import mul
from functools import reduce
def comb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
N,A,B = map(int,input().split())
V=list(map(int,input().split()))
V_C=Counter(V)
max_val=max(V)
CC=V_C[max_val]
if A<=CC<=B:
ans=0
for v in range(A,min(B,CC)+1):
ans+=comb(CC,v)
print(max_val)
print(ans)
exit()
tmp_sum=0
tmp_num=0
for key in sorted(V_C.keys(),reverse=True):
val = V_C[key]
assert tmp_num<A
#่ฟฝๅ ใใฆใๅคงไธๅคซใชใๅ ใใ(ๅ ใใชใใจAใซ่กใใชใใใๅ ใใชใใจใใใชใ)
#ใใAใซๅฑใใใใซ่ฟฝๅ ใใใฎใ่ฏใ
if A<=tmp_num+val:
rest=A-tmp_num
tmp_num+=rest
tmp_sum+=key*rest
assert tmp_num==A
assert rest<=val
assert rest!=0
assert val!=rest
print(tmp_sum/tmp_num)
print(comb(val,rest))
exit()
else:
tmp_num+=val
tmp_sum+=key*val
assert 1==2
|
s222754064 | p03776 | u375616706 | 1595123184 | Python | PyPy3 (7.3.0) | py | Runtime Error | 86 | 74856 | 1081 | from collections import Counter
from math import factorial
from operator import mul
from functools import reduce
def comb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
N,A,B = map(int,input().split())
V=list(map(int,input().split()))
V_C=Counter(V)
max_val=max(V)
CC=V_C[max_val]
if A<=CC<=B:
ans=0
for v in range(A,min(B,CC)+1):
ans+=comb(CC,v)
print(max_val)
print(ans)
exit()
tmp_sum=0
tmp_num=0
for key in sorted(V_C.keys(),reverse=True):
val = V_C[key]
assert tmp_num<A
#่ฟฝๅ ใใฆใๅคงไธๅคซใชใๅ ใใ(ๅ ใใชใใจAใซ่กใใชใใใๅ ใใชใใจใใใชใ)
#ใใAใซๅฑใใใใซ่ฟฝๅ ใใใฎใ่ฏใ
if A<=tmp_num+val:
rest=A-tmp_num
tmp_num+=rest
tmp_sum+=key*rest
assert tmp_num==A
assert 1==2
print(tmp_sum/tmp_num)
print(comb(val,rest))
exit()
else:
tmp_num+=val
tmp_sum+=key*val
assert 1==2
|
s832768865 | p03776 | u375616706 | 1595123078 | Python | PyPy3 (7.3.0) | py | Runtime Error | 104 | 74484 | 869 | from collections import Counter
from math import factorial
from scipy.special import comb
N,A,B = map(int,input().split())
V=list(map(int,input().split()))
V_C=Counter(V)
max_val=max(V)
CC=V_C[max_val]
if A<=CC<=B:
ans=0
for v in range(A,min(B,CC)+1):
ans+=comb(CC,v)
print(max_val)
print(ans)
exit()
tmp_sum=0
tmp_num=0
for key in sorted(V_C.keys(),reverse=True):
val = V_C[key]
assert tmp_num<A
#่ฟฝๅ ใใฆใๅคงไธๅคซใชใๅ ใใ(ๅ ใใชใใจAใซ่กใใชใใใๅ ใใชใใจใใใชใ)
#ใใAใซๅฑใใใใซ่ฟฝๅ ใใใฎใ่ฏใ
if A<=tmp_num+val:
rest=A-tmp_num
tmp_num+=rest
tmp_sum+=key*rest
assert tmp_num==A
print(tmp_sum/tmp_num)
print(comb(val,rest))
exit()
else:
tmp_num+=val
tmp_sum+=key*val
assert 1==2
|
s160937169 | p03776 | u375616706 | 1595122285 | Python | PyPy3 (7.3.0) | py | Runtime Error | 90 | 74832 | 806 | from collections import Counter
from math import factorial
N,A,B = map(int,input().split())
V=list(map(int,input().split()))
V_C=Counter(V)
max_val=max(V)
CC=V_C[max_val]
if A<=CC<=B:
ans=0
for v in range(A,min(B+1,CC+1)):
ans+=factorial(CC)//factorial(v)//factorial(CC-v)
print(max_val)
print(ans)
exit()
tmp_sum=0
tmp_num=0
for key in sorted(V_C.keys(),reverse=True):
val = V_C[key]
if tmp_num+val<=B:
tmp_num+=val
tmp_sum+=key*val
if tmp_num>=A:
break
else:
break
if A<=tmp_num<=B:
assert 1==2
print(tmp_sum/tmp_num)
print(1)
else:
assert 1==2
rest=A-tmp_num
tmp_num+=rest
tmp_sum+=key*rest
print(tmp_sum/tmp_num)
print(factorial(val)//factorial(rest)//factorial(val-rest))
|
s606911446 | p03776 | u375616706 | 1595122256 | Python | PyPy3 (7.3.0) | py | Runtime Error | 86 | 74740 | 790 | from collections import Counter
from math import factorial
N,A,B = map(int,input().split())
V=list(map(int,input().split()))
V_C=Counter(V)
max_val=max(V)
CC=V_C[max_val]
if A<=CC<=B:
ans=0
for v in range(A,min(B+1,CC+1)):
ans+=factorial(CC)//factorial(v)//factorial(CC-v)
print(max_val)
print(ans)
exit()
tmp_sum=0
tmp_num=0
for key in sorted(V_C.keys(),reverse=True):
val = V_C[key]
if tmp_num+val<=B:
tmp_num+=val
tmp_sum+=key*val
if tmp_num>=A:
break
else:
break
if A<=tmp_num<=B:
print(tmp_sum/tmp_num)
print(1)
else:
assert 1==2
rest=A-tmp_num
tmp_num+=rest
tmp_sum+=key*rest
print(tmp_sum/tmp_num)
print(factorial(val)//factorial(rest)//factorial(val-rest))
|
s530213610 | p03776 | u375616706 | 1595120078 | Python | PyPy3 (7.3.0) | py | Runtime Error | 88 | 74768 | 389 | from collections import Counter
N,A,B = map(int,input().split())
V=list(map(int,input().split()))
V_C=Counter(V)
tmp_sum=0
tmp_num=0
for key in sorted(V_C.keys(),reverse=True):
val = V_C[val]
if tmp_num+val<=B:
tmp_num+=val
tmp_sum+=key*val
if tmp_num>=A:
break
else:
#Aๅใซใชใใพใง่ฟฝๅ ใใ
exit()
print(tmp_sum/tmp_num)
print(1)
|
s856576449 | p03776 | u514687406 | 1594873951 | Python | Python (3.8.2) | py | Runtime Error | 31 | 9348 | 460 | import sys
import collections
input = lambda: sys.stdin.readline()
exec("try:sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w')\nexcept:pass")
n, a, b = map(int, input().split())
A = list(map(int, input().split()))
d = collections.Counter(A)
A.sort(reverse=1)
ans = []
for i in range(a, b):
ans.append([sum(A[:i]) / i, i])
maxx = max(ans, key=lambda i: i[0])
comd = 1
for i in range(maxx[1]):
comd *= d[A[i]]
print(maxx[0])
print(comd)
|
s636139620 | p03776 | u633450100 | 1591737125 | Python | Python (3.4.3) | py | Runtime Error | 158 | 13172 | 746 | if __name__ == '__main__':
from collections import Counter
from scipy.mist import comb
N,A,B = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]
V.sort(reverse = True)
max_list = [V[0:A]]
max = sum(V[0:A]) / A
for i in range(A+1,B+1):
a = sum(V[0:i]) / i
if max <= a:
max_list.append(V[0:i])
max = a
print("{:.6f}".format(max))
ans = 0
for x in max_list:
ans_sub = 1
try:
x = Counter(x).most_common()
except TypeError:
ans += ans_sub
continue
for i in range(len(x)):
ans_sub *= comb(V.count(x[i][0]),x[i][1])
ans += ans_sub
print(int(ans))
|
s853085645 | p03776 | u633450100 | 1591737061 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3316 | 748 | if __name__ == '__main__':
from collections import Counter
from mist.special import comb
N,A,B = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]
V.sort(reverse = True)
max_list = [V[0:A]]
max = sum(V[0:A]) / A
for i in range(A+1,B+1):
a = sum(V[0:i]) / i
if max <= a:
max_list.append(V[0:i])
max = a
print("{:.6f}".format(max))
ans = 0
for x in max_list:
ans_sub = 1
try:
x = Counter(x).most_common()
except TypeError:
ans += ans_sub
continue
for i in range(len(x)):
ans_sub *= comb(V.count(x[i][0]),x[i][1])
ans += ans_sub
print(int(ans))
|
s541597532 | p03776 | u633450100 | 1591735571 | Python | Python (3.4.3) | py | Runtime Error | 181 | 14328 | 598 | if __name__ == '__main__':
from collections import Counter
from scipy.special import comb
N,A,B = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]
V.sort(reverse = True)
max_list = V[0:A]
max = sum(V[0:A]) / A
for i in range(A+1,B+1):
a = sum(V[0:i]) / i
if max < a:
max_list = V[0:i]
max = a
print("{:.6f}".format(max))
ans = 1
max_list = Counter(max_list).most_common()
for i in range(len(max_list)):
ans *= comb(V.count(max_list[i][0]),max_list[i][1])
print(int(ans))
|
s594994583 | p03776 | u991134049 | 1591453863 | Python | PyPy3 (2.4.0) | py | Runtime Error | 176 | 38512 | 715 | from operator import mul
from functools import reduce
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v = sorted(v)
maxv = sum(v[N-A:])/A
ans1 = maxv
minyouso = v[N-A]
maxyouso = v[N-1]
if minyouso != maxyouso:
total = v.count(minyouso)
saitei = v[N-A:].count(minyouso)
ans2 = cmb(total, saitei)
else:
total = v.count(minyouso)
saitei = v[N-A:].count(minyouso)
zouka = B-A
ans2 = 0
for i in range(zouka+1):
ans2 += cmb(total, saitei+i)
print("{:.05f}".format(ans1))
print(ans2)
|
s854919498 | p03776 | u991134049 | 1591453313 | Python | PyPy3 (2.4.0) | py | Runtime Error | 189 | 38384 | 697 | from operator import mul
from functools import reduce
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v = sorted(v)
maxv = sum(v[N-A:])/A
ans1 = maxv
minyouso = v[N-A]
maxyouso = v[N-1]
if minyouso != maxyouso:
total = v.count(minyouso)
saitei = v[N-A:].count(minyouso)
ans2 = cmb(total, saitei)
else:
total = v.count(minyouso)
saitei = v[N-A:].count(minyouso)
zouka = B-A
ans2 = 0
for i in range(zouka+1):
ans2 += cmb(total, saitei+i)
print(ans1)
print(ans2)
|
s067792342 | p03776 | u922449550 | 1590556324 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3192 | 672 | comb_memo = {}
def comb(n, r):
global comb_memo
if (n, r) in comb_memo:
return comb_memo[(n, r)]
else:
r = min(r, n-r)
res = 1
for _ in range(r):
res *= n
n -= 1
for i in range(1, r+1):
res //= i
comb_memo[(n, r)] = res
comb_memo[(n, n-r)] = res
return res
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
mu = sum(v[:A]) / A
if v[0] == mu:
R = v.count(v[0])
ans = 0
if R > A:
for i in range(A, B+1):
if i > R:
break
ans += comb(R, i)
else:
min_v = v[A-1]
n = v.count(min_v)
need = v[:A].count(min_v)
ans += comb(n, need)
print(mu)
print(ans) |
s426246337 | p03776 | u922449550 | 1590555809 | Python | Python (3.4.3) | py | Runtime Error | 1300 | 689908 | 791 | import sys
sys.setrecursionlimit(10**9)
f_memo = {0:1, 1:1}
def f(x):
global f_memo
if x in f_memo:
return f_memo[x]
else:
res = x * f(x-1)
f_memo[x] = res
return res
comb_memo = {}
def comb(n, r):
global comb_memo
if (n, r) in comb_memo:
return comb_memo[(n, r)]
else:
a = f(n)
b = f(n-r)
c = f(r)
res = a // b // c
comb_memo[(n, r)] = res
return res
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
mu = sum(v[:A]) / A
R = A-1
for i in range(A, N):
if v[i] == mu:
R = i
else:
break
R += 1
ans = 0
if R > A:
for i in range(A, B+1):
ans += comb(R, i)
else:
min_v = v[A-1]
n = v.count(min_v)
need = v[:A].count(min_v)
ans += comb(n, need)
print(mu)
print(ans) |
s276813812 | p03776 | u922449550 | 1590555741 | Python | Python (3.4.3) | py | Runtime Error | 73 | 3972 | 750 | f_memo = {0:1, 1:1}
def f(x):
global f_memo
if x in f_memo:
return f_memo[x]
else:
res = x * f(x-1)
f_memo[x] = res
return res
comb_memo = {}
def comb(n, r):
global comb_memo
if (n, r) in comb_memo:
return comb_memo[(n, r)]
else:
a = f(n)
b = f(n-r)
c = f(r)
res = a // b // c
comb_memo[(n, r)] = res
return res
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
mu = sum(v[:A]) / A
R = A-1
for i in range(A, N):
if v[i] == mu:
R = i
else:
break
R += 1
ans = 0
if R > A:
for i in range(A, B+1):
ans += comb(R, i)
else:
min_v = v[A-1]
n = v.count(min_v)
need = v[:A].count(min_v)
ans += comb(n, need)
print(mu)
print(ans) |
s037637007 | p03776 | u497952650 | 1590106199 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 409 | nCr = {}
def cmb(n, r):
if r == 0 or r == n: return 1
if r == 1: return n
if (n,r) in nCr: return nCr[(n,r)]
nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
return nCr[(n,r)]
N,A,B = map(int,input().split())
v = sorted(list(map(int,input().split())),reverse=True)
if len(set(v)) == 1:
print(xx)
m = sum(v[:A])/A
print(m)
n = v[:A].count(min(v[:A]))
m = v.count(min(v[:A]))
print(cmb(m,n))
|
s336506512 | p03776 | u497952650 | 1590106162 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 419 | nCr = {}
def cmb(n, r):
if r == 0 or r == n: return 1
if r == 1: return n
if (n,r) in nCr: return nCr[(n,r)]
nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
return nCr[(n,r)]
N,A,B = map(int,input().split())
v = sorted(list(map(int,input().split())),reverse=True)
if len(set(v)) == 1:
print(xx)
m = sum(v[:A])/A
print(m)
n = v[:A].count(min(v[:A]))
m = v.count(min(v[:A]))
print(n,m)
print(cmb(m,n)) |
s228749389 | p03776 | u993435350 | 1589845119 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3688 | 908 | from operator import mul
from functools import reduce
N,A,B = map(int,input().split())
V = sorted(list(map(int,input().split())),reverse = True)
a = A - 1
top = V[0]
ans = 0
if top == V[a]:
d = 1
for i in range(a,N):
if V[i] != top:
b = i
break
if A == B:
n = reduce(mul,[t for t in range(A,b + 1)])
d = reduce(mul,[k for k in range(1,A + 1)])
ans = n / d
else:
for i in range(1,b + 1):
n = 1
d *= i
if i < A:
continue
for j in range(b,b - i,-1):
n *= j
print(n,d)
n /= d
ans += n
print(float(top))
print(int(ans))
else:
sect = V[:A]
ave = sum(sect) / A
print(ave)
con = V.count(V[a])
ind = V.index(V[a])
i = a - ind + 1
if a == ind:
print(con)
else:
n = reduce(mul,[t for t in range(con - i + 1,con + 1)])
d = reduce(mul,[k for k in range(1,i + 1)])
print(int(n/d))
|
s099430643 | p03776 | u993435350 | 1589842481 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3572 | 782 | import itertools
import collections
from operator import mul
from functools import reduce
N,A,B = map(int,input().split())
V = sorted(list(map(int,input().split())),reverse = True)
a = A - 1
top = V[0]
ans = 0
if top == V[a]:
d = 1
for i in range(1,B + 1):
if V[i] != top:
B = i
break
for i in range(1,B + 1):
n = 1
d *= i
if i < A:
continue
for j in range(B,B - i,-1):
n *= j
n /= d
ans += n
print(float(top))
print(int(ans))
else:
sect = V[:A]
ave = sum(sect) / A
print(ave)
con = V.count(V[a])
ind = V.index(V[a])
i = a - ind + 1
if a == ind:
print(con)
else:
n = reduce(mul,[t for t in range(con - i + 1,con + 1)])
d = reduce(mul,[k for k in range(1,i + 1)])
print(int(n/d))
|
s444955217 | p03776 | u993435350 | 1589839470 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3692 | 707 | import itertools
import collections
from operator import mul
from functools import reduce
N,A,B = map(int,input().split())
V = sorted(list(map(int,input().split())),reverse = True)
ans = 0
if len(set(V)) == 1:
d = reduce(mul,[i for i in range(1,A)])
for i in range(A,B + 1):
n = 1
d *= i
for j in range(B,B - i,-1):
n *= j
n /= d
ans += n
print(float(V[0]))
print(int(ans))
else:
a = A - 1
sect = V[:A]
ave = sum(sect) / A
print(ave)
con = V.count(V[a])
ind = V.index(V[a])
i = a - ind + 1
if a == ind:
print(con)
else:
n = reduce(mul,[t for t in range(con - i + 1,con + 1)])
d = reduce(mul,[k for k in range(1,i + 1)])
print(int(n/d)) |
s345692310 | p03776 | u993435350 | 1589836241 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3684 | 755 | import itertools
import collections
from operator import mul
from functools import reduce
N,A,B = map(int,input().split())
V = sorted(list(map(int,input().split())),reverse = True)
total = 0
pattern = 0
if len(set(V)) == 1:
for i in range(1,B):
c = 1
for j in range(B,B - i,-1):
c *= j
d = [t for t in range(1,i + 1)]
d = reduce(mul,d)
c /= d
pattern += c
a = A - 1
print(float(V[0]))
print(int(pattern) + 1)
else:
a = A - 1
sect = V[:A]
total += sum(sect) / A
print(total)
con = V.count(V[a])
ind = V.index(V[a])
C = con - ind
if con == ind:
print(1)
else:
numer = reduce(mul,[k for k in range(C,con + 1)])
denom = reduce(mul,[k for k in range(1,C + 1)])
print(int(numer/denom)) |
s799039276 | p03776 | u250795848 | 1589753011 | Python | PyPy3 (2.4.0) | py | Runtime Error | 183 | 38640 | 403 | import sys
def main():
input = sys.stdin.readline
N, K = map(int, input().split())
count = 0
d = []
l = {}
for i in range(N):
a,b = map(int, input().split())
d.append(a)
l[a] = b
d.sort()
for i in d:
count += l[i]
if count >= K:
print(i)
break
if __name__ == "__main__":
main()
|
s191443705 | p03776 | u250795848 | 1589708986 | Python | PyPy3 (2.4.0) | py | Runtime Error | 182 | 38384 | 2367 | import sys
from collections import deque
import math
import numpy as np
def main():
def perm(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
input = sys.stdin.readline
N, A, B = map(int, input().split())
d = [0] * N
q = []
d[:] = map(int, input().split())
dic={}
dic_d = {}
k = 0
d.sort(reverse=True)
s = sum(d[:A])
m = s/A
for i in set(d):
dic_d[i] = d.count(i)
print("{:.6f}".format(m))
for i in set(d):
l = len(q)
if l > 0:
for j in range(l):
for h in range(len(dic[q[j]])):
if dic[q[j]][h][0] >= B:
break
s = q[j] * dic[q[j]][h][0] + i
ave = s/(dic[q[j]][h][0]+1)
if not ave in q:
dic[ave] = []
q.append(ave)
dic[ave].append([dic[q[j]][h][0]+1,dic[q[j]][h][1]])#[j]][g][1]] for g in range(len(dic[q[j]]))]
elif ave in q:
for g in range(len(dic[q[j]])):
ave_j = np.array(dic[ave])
if not dic[q[j]][g][0]+1 in ave_j[:,0]:
dic[ave].append([dic[q[j]][h][0]+1,dic[q[j]][h][1]])
else:
for f in range(len(dic[ave])):
if dic[ave][f][0] == dic[q[j]][g][0]+1:
dic[ave][f][1] += 1
if not i in q:
q.append(i)
dic[i] = []
for h in range(1, dic_d[i]+1):
dic[i].append([h,int(perm(dic_d[i],h))])
elif i in q:
for h in range(1,dic_d[i]+1):
if dic[i][h][0] <= dic_d[i]:
dic[i][h][1] += perm(dic_d[i],dic[i][h][0])
else:
dic[i].append([h, perm(dic_d[i],h)])
ave_np = np.array(dic[m])
for i in range(len(dic[m])):
if ave_np[i,0] <= B:
ave_count = sum(ave_np[:i+1,1])
print(ave_count)
if __name__ == "__main__":
main()
|
s466126951 | p03776 | u250795848 | 1589708790 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38384 | 2350 | import sys
from collections import deque
import math
import numpy as np
def main():
def perm(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
input = sys.stdin.readline
N, A, B = map(int, input().split())
d = [0] * N
q = []
d[:] = map(int, input().split())
dic={}
dic_d = {}
k = 0
d.sort(reverse=True)
s = sum(d[:A])
m = s/A
for i in set(d):
dic_d[i] = d.count(i)
print(m)
for i in set(d):
l = len(q)
if l > 0:
for j in range(l):
for h in range(len(dic[q[j]])):
if dic[q[j]][h][0] >= B:
break
s = q[j] * dic[q[j]][h][0] + i
ave = s/(dic[q[j]][h][0]+1)
if not ave in q:
dic[ave] = []
q.append(ave)
dic[ave].append([dic[q[j]][h][0]+1,dic[q[j]][h][1]])#[j]][g][1]] for g in range(len(dic[q[j]]))]
elif ave in q:
for g in range(len(dic[q[j]])):
ave_j = np.array(dic[ave])
if not dic[q[j]][g][0]+1 in ave_j[:,0]:
dic[ave].append([dic[q[j]][h][0]+1,dic[q[j]][h][1]])
else:
for f in range(len(dic[ave])):
if dic[ave][f][0] == dic[q[j]][g][0]+1:
dic[ave][f][1] += 1
if not i in q:
q.append(i)
dic[i] = []
for h in range(1, dic_d[i]+1):
dic[i].append([h,int(perm(dic_d[i],h))])
elif i in q:
for h in range(1,dic_d[i]+1):
if dic[i][h][0] <= dic_d[i]:
dic[i][h][1] += perm(dic_d[i],dic[i][h][0])
else:
dic[i].append([h, perm(dic_d[i],h)])
ave_np = np.array(dic[m])
for i in range(len(dic[m])):
if ave_np[i,0] <= B:
ave_count = sum(ave_np[:i+1,1])
print(ave_count)
if __name__ == "__main__":
main()
|
s095608351 | p03776 | u600402037 | 1588299728 | Python | Python (3.4.3) | py | Runtime Error | 154 | 12648 | 683 | # coding: utf-8
import sys
import numpy as np
from math import factorial
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, A, B = lr()
V = np.array(lr(), np.float64)
V.sort()
V = V[::-1]
Vcum = V.cumsum()
ave = Vcum / np.arange(1, N+1)
ma = ave[A-1:B].max()
print(ma)
cases = 0
Vrev = V[::-1]
for i, x in enumerate(ave[A-1:B], A-1):
if x != ma:
continue
j = np.searchsorted(Vrev, V[i])
k = np.searchsorted(Vrev, V[i], side='right')
if j+1 == k:
cases += 1
continue
r = i+1-j
n = k-j
a = factorial(n) / factorial(r) / factorial(n - r)
cases += a
print(int(cases))
|
s406456664 | p03776 | u600402037 | 1588299622 | Python | Python (3.4.3) | py | Runtime Error | 148 | 12512 | 689 | # coding: utf-8
import sys
import numpy as np
from math import factorial
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, A, B = lr()
V = np.array(lr(), np.float64)
V.sort()
V = np.flip(V)
Vcum = V.cumsum()
ave = Vcum / np.arange(1, N+1)
ma = ave[A-1:B].max()
print(ma)
cases = 0
Vrev = np.flip(V)
for i, x in enumerate(ave[A-1:B], A-1):
if x != ma:
continue
j = np.searchsorted(Vrev, V[i])
k = np.searchsorted(Vrev, V[i], side='right')
if j+1 == k:
cases += 1
continue
r = i+1-j
n = k-j
a = factorial(n) / factorial(r) / factorial(n - r)
cases += a
print(int(cases))
|
s366870997 | p03776 | u871980676 | 1588299205 | Python | Python (3.4.3) | py | Runtime Error | 188 | 14432 | 868 | from scipy.special 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)
|
s876360709 | p03776 | u342075214 | 1588298415 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 1021 | #include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;
map<int,int> lar;
signed main(){
int N,A,B;cin>>N>>A>>B;
vector<int>V(N);
REP(i,N)cin>>V[i];
sort(V.rbegin(),V.rend());
double maxave=0;
int stop=0;
for(int i=A;i<=B;i++){
double d=0;
REP(j,i)d+=V[j];
d/=A;
maxave=max(d,maxave);
if(V[i-1]!=V[i]){
stop=i;
break;
}
}
cout<<maxave<<endl;
map<int,int>memo;
int count=0;
for(int i=stop-1;i>=0;i--){
if(V[i]=V[stop-1])count++;
}
if(N!=count) cout<<count*(count-1)/2<<endl;
else{
int ans=0;
for(int i=A;i<=B;i++){
int ret=1;
for(int j=0;j<i;j++){
ret*=(N-j);
ret/=(j+1);
}
ans+=ret;
}
cout<<ans<<endl;
}
}
|
s045129940 | p03776 | u995062424 | 1588218147 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 848 | 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(num[0] == num[-1]):
exa = 0
for i in range(A, 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() |
s980478257 | p03776 | u995062424 | 1588216875 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3316 | 857 | 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, 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() |
s911022222 | p03776 | u995062424 | 1588213728 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 815 | 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(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(te)):
if(te[i] == 1):
continue
exa *= math.factorial(N-i)//(math.factorial(N-2*i-1)*math.factorial(i+1))
print(ans)
print(exa)
main() |
s047306483 | p03776 | u531436689 | 1584632864 | Python | PyPy3 (2.4.0) | py | Runtime Error | 333 | 66284 | 1404 | 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(51)
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 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()
|
s996968872 | p03776 | u531436689 | 1584632758 | Python | PyPy3 (2.4.0) | py | Runtime Error | 306 | 66924 | 1399 | 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(51)
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 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(ans)
main()
|
s033898235 | p03776 | u600402037 | 1582526209 | Python | Python (3.4.3) | py | Runtime Error | 149 | 12392 | 743 | import sys
import numpy as np
from math import factorial
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, A, B = lr()
V = np.array(lr())
V.sort()
if A == 1:
ave = V[-A]
else:
ave = V[-A:].sum() / A
print(ave)
left_i = np.searchsorted(V, V[-A], side='left')
right_i = np.searchsorted(V, V[-A], side='right')
num = right_i - left_i
done = N - right_i
bottom = A-done
top = B-done
def combinations_count(n, r):
''' ็ตใฟๅใใ '''
return factorial(n) // (factorial(n - r) * factorial(r))
answer = combinations_count(num, bottom)
if ave == V[-A] and num > 1:
for i in range(bottom+1, top+1):
answer += combinations_count(num, i)
print(answer)
# 15 |
s856126152 | p03776 | u457901067 | 1580859776 | Python | Python (3.4.3) | py | Runtime Error | 31 | 3828 | 784 | from operator import mul
from functools import reduce
from math import sqrt
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
N, A, B = list(map(int, input().split()))
V = list(map(int, input().split()))
V.sort(reverse = True)
print(sum(V[:A]) / A)
# A็ช็ฎใจไธ็ทใฎๆฐๅญใฎๆฐ๏ผAๅใใๅคใง๏ผ
cnt_ext = 0
for i in range(A,min(A+B,N)):
if V[A-1] == V[i]:
cnt_ext += 1
# A็ช็ฎใจไธ็ทใฎๆฐๅญใฎๆฐ๏ผAๅใฎไธญใง๏ผ
cnt_int = 0
for i in range(0,A):
if V[A-1] == V[i]:
cnt_int += 1
#print(cnt_int, cnt_ext)
cnt_all = cnt_int + cnt_ext
ans = 0
for i in range(A,B+1):
ans += cmb(cnt_all, cnt_int)
cnt_int += 1
print(ans) |
s715833724 | p03776 | u557494880 | 1580175676 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 520 | from math import factorial
def combi(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()
x = V[-1]
ans = 0
for i in range(1,A+1):
ans += V[-i]
x = V[-i]
ans = ans/A
print(ans)
count = 0
import bisect
y = N - bisect.bisect(V,x)
if x == V[-1]:
n = V.count(x)
for i in range(A,min(B,V.count(x))+1):
z = i - y
count += comb(n,z)
else:
z = A - y
n = V.count(x)
count += comb(n,z)
print(count) |
s739109977 | p03776 | u329407311 | 1579749882 | Python | Python (3.4.3) | py | Runtime Error | 160 | 13172 | 649 | import bisect
import math
from scipy.misc import comb
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,mini)
List = sorted(List, reverse=True)
if List[0] != List[A-1]:
B = A
for i in range(B-A+1):
n = num
kosuu = A + i - num2
ans = int(ans + math.factorial(n) // (math.factorial(n - kosuu) * math.factorial(kosuu)))
ave = int(sum(List[:A])/A)
print(ave)
print(ans) |
s630968654 | p03776 | u329407311 | 1579749785 | Python | Python (3.4.3) | py | Runtime Error | 183 | 14348 | 661 | import bisect
import math
from scipy.misc import comb
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,List[A-1])
List = sorted(List, reverse=True)
if List[0] != List[A-1]:
B = A
for i in range(B-A+1):
n = num
kosuu = max(A + i - num2,0)
ans = int(ans + math.factorial(n) // (math.factorial(n - kosuu) * math.factorial(kosuu)))
ave = int(sum(List[:A])/A)
print(ave)
print(ans) |
s627297752 | p03776 | u329407311 | 1579749694 | Python | Python (3.4.3) | py | Runtime Error | 174 | 13424 | 647 | import bisect
import math
from scipy.misc import comb
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,List[A-1])
List = sorted(List, reverse=True)
if List[0] != List[A-1]:
B = A
for i in range(B-A+1):
n = num
kosuu = A + i
ans = int(ans + math.factorial(n) // (math.factorial(n - kosuu) * math.factorial(kosuu)))
ave = int(sum(List[:A])/A)
print(ave)
print(ans) |
s701704400 | p03776 | u329407311 | 1579749638 | Python | Python (3.4.3) | py | Runtime Error | 205 | 14572 | 659 | import bisect
import math
from scipy.misc import comb
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,List[A-1])
List = sorted(List, reverse=True)
if List[0] != List[A-1]:
B = A
for i in range(B-A+1):
n = num
kosuu = int(A + i - num2)
ans = int(ans + math.factorial(n) // (math.factorial(n - kosuu) * math.factorial(kosuu)))
ave = int(sum(List[:A])/A)
print(ave)
print(ans) |
s924486749 | p03776 | u329407311 | 1579749571 | Python | Python (3.4.3) | py | Runtime Error | 196 | 15220 | 603 | import bisect
import math
from scipy.misc import comb
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,List[A-1])
List = sorted(List, reverse=True)
if List[0] != List[A-1]:
B = A
for i in range(B-A+1):
n = num
kosuu = A + i - num2
ans = int(ans + math.factorial(kosuu))
ave = int(sum(List[:A])/A)
print(ave)
print(ans) |
s239219629 | p03776 | u329407311 | 1579749533 | Python | Python (3.4.3) | py | Runtime Error | 164 | 13172 | 634 | import bisect
import math
from scipy.misc import comb
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,List[A-1])
List = sorted(List, reverse=True)
if List[0] != List[A-1]:
B = A
for i in range(B-A+1):
n = num
kosuu = A + i - num2
ans = int(ans + (math.factorial(n - kosuu) * math.factorial(kosuu)))
ave = int(sum(List[:A])/A)
print(ave)
print(ans) |
s727504353 | p03776 | u329407311 | 1579749492 | Python | Python (3.4.3) | py | Runtime Error | 159 | 13172 | 653 | import bisect
import math
from scipy.misc import comb
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,List[A-1])
List = sorted(List, reverse=True)
if List[0] != List[A-1]:
B = A
for i in range(B-A+1):
n = num
kosuu = A + i - num2
ans = int(ans + math.factorial(n) / (math.factorial(n - kosuu) * math.factorial(kosuu)))
ave = int(sum(List[:A])/A)
print(ave)
print(ans) |
s321484602 | p03776 | u329407311 | 1579749459 | Python | Python (3.4.3) | py | Runtime Error | 174 | 14060 | 654 | import bisect
import math
from scipy.misc import comb
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,List[A-1])
List = sorted(List, reverse=True)
if List[0] != List[A-1]:
B = A
for i in range(B-A+1):
n = num
kosuu = A + i - num2
ans = int(ans + math.factorial(n) // (math.factorial(n - kosuu) * math.factorial(kosuu)))
ave = int(sum(List[:A])/A)
print(ave)
print(ans) |
s303182783 | p03776 | u329407311 | 1579747942 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 580 | import bisect
import math
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,List[A-1])
List = sorted(List, reverse=True)
for i in range(B-A+1):
n = num
kosuu = A + i - num2
ans = ans + math.factorial(n) // (math.factorial(n - kosuu) * math.factorial(kosuu))
ave = sum(List[:A])/A
print(ave)
print(ans) |
s545739080 | p03776 | u329407311 | 1579747723 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 616 | import bisect
import math
N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)
mini = List[A-1]
ans = 0
if List[A-1] != List[A]:
ans = sum(List[:A])/A
print(ans)
print(1)
else:
num = List.count(List[A-1])
List = sorted(List)
num2 = N - bisect.bisect_right(List,List[A-1])
List = sorted(List, reverse=True)
if List[0] != List[A-1]:
B = A
for i in range(B-A+1):
n = num
kosuu = A + i - num2
ans = ans + math.factorial(n) // (math.factorial(n - kosuu) * math.factorial(kosuu))
ave = sum(List[:A])/A
print(ave)
print(ans) |
s189599458 | p03776 | u970197315 | 1579358589 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3316 | 906 | # ABC057 D - Maximum Average Sets
from collections import defaultdict
from math import factorial
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def perm(n,r):
return factorial(n)//factorial(n-r)
def comb(n,r):
return perm(n,r)//factorial(r)
n,a,b=nm()
V=nl()
d=defaultdict(int)
for vv in V:
d[vv]+=1
value=0
cnt=0
ans=0
V=list(set(V))
if len(V)==1:
print(V[0])
print(2**(b-a+1)-1)
exit()
for k,v in sorted(d.items(),key=lambda x:x[0],reverse=True):
if a>=v:
value+=k*v
cnt+=v
a-=v
b-=v
elif a<v:
if a==0 and v==1:
one_flg=True
for i in range(a,min(b,v)):
value+=k*a
cnt+=a
nn=v
kk=a
ans=comb(nn, kk)
break
if one_flg:
ans=1
print(value/cnt)
print(ans)
|
s436928922 | p03776 | u970197315 | 1579325500 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 1052 | # ABC057 D - Maximum Average Sets
from collections import defaultdict
from math import factorial
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def perm(n,r):
return factorial(n)//factorial(n-r)
def comb(n,r):
return perm(n,r)//factorial(r)
n,a,b=nm()
V=nl()
d=defaultdict(int)
for vv in V:
d[vv]+=1
value=0
cnt=0
ans=0
one_flg=False
V=list(set(V))
if len(V)==1:
print(V[0])
print(2**(b-a+1)-1)
exit()
for k,v in sorted(d.items(),key=lambda x:x[0],reverse=True):
if a>=v:
value+=k*v
cnt+=v
a-=v
b-=v
elif a<v:
if a==0 and v==1:
one_flg=True
elif b==v and b!=0:
print(k)
print(2**b-1)
exit()
else:
for i in range(a,b+1):
value+=k*i
cnt+=i
nn=v
kk=i
ans+=comb(nn, kk)
break
if one_flg:
ans=1
print(value/cnt)
print(ans) |
s539549220 | p03776 | u970197315 | 1579323584 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 942 | # ABC057 D - Maximum Average Sets
from collections import defaultdict
from math import factorial
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def perm(n,r):
return factorial(n)//factorial(n-r)
def comb(n,r):
return perm(n,r)//factorial(r)
n,a,b=nm()
V=nl()
d=defaultdict(int)
for vv in V:
d[vv]+=1
value=0
cnt=0
ans=0
V=list(set(V))
if len(V)==1:
print(V[0])
print(2**(b-a+1)-1)
exit()
for k,v in sorted(d.items(),key=lambda x:x[0],reverse=True):
if a==0:
if b==v:
print(k)
print(2**b-1)
exit()
break
elif a>=v:
value+=k*v
cnt+=v
a-=v
b-=v
elif a<v:
for i in range(a,b):
value+=k*i
cnt+=i
nn=v
kk=i
ans=comb(nn, kk)
break
print(value/cnt)
print(ans)
|
s064804894 | p03776 | u989345508 | 1578585352 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 893 | import math
#from scipy.special import comb
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def groupby(a):
a2=[[a[0],1]]
for i in range(1,len(a)):
if a2[-1][0]==a[i]:
a2[-1][1]+=1
else:
a2.append([a[i],1])
return a2
N,A,B=map(int,input().split())
v=[int(i) for i in input().split()]
v.sort(reverse=True)
v=groupby(v)
if A<=v[0][1]:
#ใใฃใกใ้้ใฃใฆใ
m=min(v[0][1],B)
for i in range(A,m+1):
co-=combinations_count(v[0][1],i)
print(v[0][0])
print(co)
else:
al=0
l=len(v)
C=0
for i in range(l):
C+=v[i][1]
if C<=A:
al+=(v[i][0]*v[i][1])
else:
C-=v[i][1]
al+=(v[i][0]*(A-C))
k=combinations_count(v[i][1],A-C)
break
print(al/A)
print(k)
|
s192637337 | p03776 | u989345508 | 1578584666 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 918 | import math
#from scipy.special import comb
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def groupby(a):
a2=[[a[0],1]]
for i in range(1,len(a)):
if a2[-1][0]==a[i]:
a2[-1][1]+=1
else:
a2.append([a[i],1])
return a2
N,A,B=map(int,input().split())
v=[int(i) for i in input().split()]
v.sort(reverse=True)
v=groupby(v)
if A<=v[0][1]:
#ใใฃใกใ้้ใฃใฆใ
m=min(v[0][1],B)
co=2**m
for i in range(A):
co-=combinations_count(m,i)
print(v[0][0])
print(co)
if A==m:
r
else:
al=0
l=len(v)
C=0
for i in range(l):
C+=v[i][1]
if C<=A:
al+=(v[i][0]*v[i][1])
else:
C-=v[i][1]
al+=(v[i][0]*(A-C))
k=combinations_count(v[i][1],A-C)
break
print(al/A)
print(k)
|
s819804454 | p03776 | u989345508 | 1578584188 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 868 | import math
#from scipy.special import comb
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def groupby(a):
a2=[[a[0],1]]
for i in range(1,len(a)):
if a2[-1][0]==a[i]:
a2[-1][1]+=1
else:
a2.append([a[i],1])
return a2
N,A,B=map(int,input().split())
z=[int(i) for i in input().split()]
z.sort(reverse=True)
v=groupby(z)
if A<=v[0][1]:
m=min(v[0][1],B)
co=2**m
for i in range(A):
co-=combinations_count(m,i)
print(v[0][0])
print(co)
else:
r
al=0
l=len(v)
C=0
for i in range(l):
C+=v[i][1]
if C<=A:
al+=(v[i][0]*v[i][1])
else:
C-=v[i][1]
al+=(v[i][0]*(A-C))
k=combinations_count(v[i][1],A-C)
break
print(al/A)
print(k)
|
s238062325 | p03776 | u989345508 | 1578582187 | Python | Python (3.4.3) | py | Runtime Error | 160 | 15240 | 936 | import math
from scipy.special import comb
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def groupby(a):
a2=[[a[0],1]]
for i in range(1,len(a)):
if a2[-1][0]==a[i]:
a2[-1][1]+=1
else:
a2.append([a[i],1])
return a2
n,A,B=map(int,input().split())
v=[int(i) for i in input().split()]
v.sort(reverse=True)
v=groupby(v)
if A<=v[0][1]:
m=min(v[0][1],B)
co=0
#print(m-A)
for i in range(A,m+1):
co+=combinations_count(m,i)
#co+=comb(m,A,exact=True)
print(v[0][0])
print(co)
else:
al=0
l=len(v)
B=A
k=1
for i in range(l):
B-=v[i][1]
if B>=0:
al+=(v[i][0]*v[i][1])
else:
B+=v[i][1]
al+=(v[i][0]*B)
k=combinations_count(v[i][1],B)
#k=comb(v[i][1],B,exact=True)
print(al/A)
print(k)
|
s908097803 | p03776 | u380933932 | 1578460185 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 683 | nab=list(map(int,input().split()))
v=list(map(int,input().split()))
v.sort(reverse=True)
vmin=v[:nab[1]]
print(sum(vmin)/len(vmin))
mini=1
if len(vmin)>1:
for i in range(nab[1]):
if vmin[-2-i]==vmin[-1]:
mini+=1
else:
break
ex=0
if nab[1]<nab[2]:
for i in range(nab[0]-nab[1]):
if v[nab[1]+i]==vmin[-1]:
ex+=1
else:
break
def f(n):
out=1
for i in range(1,n+1):
out*=i
return out
ans=0
if vmin[0]!=vmin[-1]:
ans=f(mini+ex)//(f(mini)*f(ex))
print(ans)
else:
m=min(nab[2]-nab[1],ex)
for i in range(m+1):
ans+=f(mini+m)//(f(mini+i)*f(m-i))
print(ans)
|
s147600407 | p03776 | u380933932 | 1578460085 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 691 | nab=list(map(int,input().split()))
v=list(map(int,input().split()))
v.sort(reverse=True)
vmin=v[:nab[1]]
print(sum(vmin)/len(vmin))
mini=1
if len(vmin)>1:
for i in range(nab[1]):
if vmin[-2-i]==vmin[-1]:
mini+=1
else:
break
ex=0
if nab[1]<nab[2]:
for i in range(nab[0]-nab[1]):
if v[nab[1]+i]==vmin[-1]:
ex+=1
else:
break
def f(n):
out=1
for i in range(1,n+1):
out*=i
return out
ans=0
if vmin[0]!=vmin[-1]:
ans=int(f(mini+ex)/(f(mini)*f(ex)))
print(ans)
else:
m=min(nab[2]-nab[1],ex)
for i in range(m+1):
ans+=int(f(mini+m)/(f(mini+i)*f(m-i)))
print(ans)
|
s285874084 | p03776 | u380933932 | 1578459882 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 555 | nab=list(map(int,input().split()))
v=list(map(int,input().split()))
v.sort(reverse=True)
vmin=v[:nab[1]]
print(sum(vmin)/len(vmin))
mini=1
if len(vmin)>1:
for i in range(nab[1]):
if vmin[-2-i]==vmin[-1]:
mini+=1
else:
break
ex=0
if nab[1]<nab[2]:
for i in range(nab[0]-nab[1]):
if v[nab[1]+i]==vmin[0]:
ex+=1
else:
break
def f(n):
out=1
for i in range(1,n+1):
out*=i
return out
m=min(nab[2]-nab[1],ex)
ans=int(f(min+ex)/(f(min)*f(ex)))
print(ans)
|
s096444141 | p03776 | u380933932 | 1578459220 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 590 | nab=list(map(int,input().split()))
v=list(map(int,input().split()))
v.sort(reverse=True)
vmin=v[:nab[1]]
print(sum(vmin)/len(vmin))
mini=1
if len(vmin)>1:
for i in range(nab[1]):
if vmin[-2-i]==vmin[-1]:
mini+=1
else:
break
ex=0
if nab[1]<nab[2]:
for i in range(nab[0]-nab[1]):
if v[nab[1]+i]==vmin[-1]:
ex+=1
else:
break
def f(n):
out=1
for i in range(1,n+1):
out*=i
return out
m=min(nab[2]-nab[1],ex)
ans=1
for i in range(m):
ans+=int(f(mini+m)/(f(mini+i)*f(m-i)))
print(ans)
|
s805983031 | p03776 | u314089899 | 1576903284 | Python | Python (3.4.3) | py | Runtime Error | 175 | 14360 | 787 | #57d
from bisect import bisect_left, bisect_right
from scipy.special import comb
N,A,B = map(int, input().split())
v_list = [int(e) for e in input().split()]
v_list.sort(reverse = True)
print(sum(v_list[0:A])/A)
min_value = v_list[A-1]
v_list.sort(reverse=False)
min_value_left = bisect_left(v_list, min_value)
min_value_right = bisect_right(v_list, min_value)
duplicated = min_value_right - min_value_left #ๆๅฐๅคใฎ้่คๅๆฐ
fixed = N - min_value_right #ๅบๅฎใใใฆใใๅๆฐ
ans = 0
#print(fixed)
#print(duplicated)
min_choice = max(1,A - fixed)
if fixed==0:
max_choice = B + 1
else:
max_choice = B - fixed
if min_choice != max_choice:
for i in range(min_choice,max_choice):
ans += comb(duplicated, i, exact=True)
else:
ans = 1
print(ans) |
s532018081 | p03776 | u777068250 | 1576902791 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 701 | def count(v,n,x):
result = 0
for i in range(n):
if v[i] == x:
result += 1
return result
def getAverage(v,a):
result = 0
for i in range(a):
result += v[i]
return result/a
choose = [[1]*51 for i in range(51)]
for i in range(1,51):
for j in range(1,i):
choose[i][j] = choose[i-1][j] + choose[i-1][j-1]
n,a,b = [int(x) for x in input().split()]
v = [int(x) for x in input().split()]
v.sort()
v = v[::-1]
ans = 0
min = v[a-1]
i=0
while (getAverage(v,a)==getAverage(v,a+i) and a+i<=b):
count1 = count(v,a+i,min)
count2 = count(v,len(v),min)
ans += choose[count2][count1]
i += 1
print("%.9f" % (getAverage(v,a)))
print(ans) |
s153569506 | p03776 | u503283842 | 1576881574 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 864 | def ncr(x,y):
ans=1
q=x-y
while x>y:
ans*=x
x=x-1
while q>1:
ans=ans/q
q=q-1
return ans
x=input().split()
n=int(x[0])
a=int(x[1])
b=int(x[2])
v=[0]*n
x = input().split()
ind=0
M={1:0}
M2={1:0}
for i in x:
v[ind]=int(i)
if int(i) in M:
M[v[ind]]+=1
else:
M[v[ind]]=1
ind+=1
v.sort(reverse=True)
cnt=0
ind=0
m=0
while cnt<a:
cnt+=1
m=((cnt-1)*m+v[ind])/cnt
if v[ind] in M2:
M2[v[ind]]+=1
else:
M2[v[ind]]=1
ind+=1
while cnt<b:
print(cnt,v[ind])
if (cnt*m+v[ind])/(cnt+1)<m-0.5:
break
else:
cnt+=1;
if v[ind] in M2:
M2[v[ind]]+=1
else:
M2[v[ind]]=1
ind+=1
print(M[795366679311762],M2[795366679311762])
print(m)
maxw=cnt;
ways=0;
for i in range(cnt,a-1,-1):
if v[ind-1] not in M2:
M2[v[ind]]=0
if v[ind-1] not in M:
M[v[ind-1]]=0
ways+=ncr(M[v[ind-1]],M2[v[ind-1]])
M2[v[ind-1]]-=1
print(int(ways))
|
s405678621 | p03776 | u503283842 | 1576880211 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 818 | def ncr(x,y):
ans=1
q=x-y
while x>y:
ans*=x
x=x-1
while q>1:
ans=ans/q
q=q-1
return ans
x=input().split()
n=int(x[0])
a=int(x[1])
b=int(x[2])
v=[0]*n
x = input().split()
ind=0
M={1:0}
M2={1:0}
for i in x:
v[ind]=int(i)
if int(i) in M:
M[v[ind]]+=1
else:
M[v[ind]]=1
ind+=1
v.sort(reverse=True)
cnt=0
ind=0
m=0
while cnt<a:
cnt+=1
m=((cnt-1)*m+v[ind])/cnt
if v[ind] in M2:
M2[v[ind]]+=1
else:
M2[v[ind]]=1
ind+=1
while cnt<b:
if (cnt*m+v[ind])/(cnt+1)<m:
break
else:
cnt+=1;
m=((cnt-1)*m+v[ind])/cnt
if v[ind] in M2:
M2[v[ind]]+=1
else:
M2[v[ind]]=1
ind+=1
print(m)
maxw=cnt;
ways=0;
for i in range(cnt,a-1,-1):
if v[ind] not in M2:
M2[v[ind]]=0
if v[ind-1] not in M:
M[v[ind-1]]=0
ways+=ncr(M[v[ind-1]],M2[v[ind-1]])
M2[v[ind]]-=1
print(int(ways))
|
s710182437 | p03776 | u254871849 | 1576827563 | Python | Python (3.4.3) | py | Runtime Error | 209 | 15196 | 632 | import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r
import scipy.special
def comb(n, r):
return scipy.special.comb(n, r, exact=True)
n, a, b, *v = map(int, sys.stdin.read().split())
def main():
v.sort()
ma = v[n-a:n]
yield sum(ma) / a
lo = ma[0]
hi = ma[-1]
res = 0
lo_cnt = bi_r(v, lo) - bi_l(v, lo)
if lo == hi:
for c in range(a, min(b, lo_cnt) + 1):
res += comb(lo_cnt, c)
else:
allowed_cnt = bi_r(ma, lo)
res = comb(lo_cnt, allowed_cnt)
yield res
if __name__ == '__main__':
ans = main()
print(*ans, sep='\n') |
s997298436 | p03776 | u905582793 | 1576568102 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 578 | from math import factorial
import bisect
def cmb(n,r):
if n<0 or r<0:
return 0
else:
return factorial(n)//factorial(n-r)//factorial(r)
n,a,b=map(int,input().split())
x = list(map(int,input().split()))
ans=0
x.sort(reverse=True)
print(sum(x[:a])/a)
if n==a:
print(1)
elif x[0]==x[a]:
for i in range(n):
if x[0] != x[i]:
k=i
break
else:
k=n
for i in range(a,b+1):
ans+=cmb(k,i)
print(ans)
elif x[a-1] == x[a]:
y=sorted(x)
x1=bisect.bisect_left(y,x[a])
x2=bisect.bisect_right(y,x[a])
print(cmb(x2-x1,a-(n-x2)))
else:
print(1) |
s700836926 | p03776 | u905582793 | 1576567942 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 556 | from math import factorial
import bisect
def cmb(n,r):
if n<0 or r<0:
return 0
else:
return factorial(n)//factorial(n-r)//factorial(r)
n,a,b=map(int,input().split())
x = list(map(int,input().split()))
ans=0
x.sort(reverse=True)
print(sum(x[:a])/a)
if x[0]==x[a]:
for i in range(n):
if x[0] != x[i]:
k=i
break
else:
k=n
for i in range(a,b+1):
ans+=cmb(k,i)
print(ans)
elif x[a-1] == x[a]:
y=sorted(x)
x1=bisect.bisect_left(y,x[a])
x2=bisect.bisect_right(y,x[a])
print(cmb(x2-x1,a-(n-x2)))
else:
print(1) |
s662564195 | p03776 | u905582793 | 1576567490 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 413 | from math import factorial
def cmb(n,r):
if n<0 or r<0:
return 0
else:
return factorial(n)//factorial(n-r)//factorial(r)
n,a,b=map(int,input().split())
x = list(map(int,input().split()))
ans=0
x.sort(reverse=True)
print(sum(x[:a])/a)
if x[0]==x[a]:
for i in range(n):
if x[0] != x[i]:
k=i
break
else:
k=n
for i in range(a,b+1):
ans+=cmb(k,i)
print(ans)
else:
print(1) |
s870480191 | p03776 | u332906195 | 1576348306 | Python | PyPy3 (2.4.0) | py | Runtime Error | 182 | 39152 | 474 | from math import factorial
N, A, B = map(int, input().split())
V = sorted(list(map(int, input().split())), reverse=True)
print(sum(V[:A]) / A)
if V[0] == V[A - 1]:
n = sum([1 for v in V if v == V[0]])
print(sum([factorial(n) // factorial(r) // factorial(n - r)
for r in range(A, B + 1)]))
else:
n = sum([1 for v in V if v == V[A - 1]])
r = sum([1 for v in V[:A] if v == V[A - 1]])
print(factorial(n) // factorial(r) // factorial(n - r))
|
s398103417 | p03776 | u864197622 | 1575866633 | Python | PyPy3 (2.4.0) | py | Runtime Error | 174 | 38256 | 674 | N, W = map(int, input().split())
w0, v0 = map(int, input().split())
X = [[] for _ in range(4)]
X[0].append(v0)
for _ in range(N-1):
w, v = map(int, input().split())
X[w-w0].append(v)
X = [[0] + sorted(x)[::-1] for x in X]
for i in range(4):
for j in range(1, len(X[i])):
X[i][j] += X[i][j-1]
ma = 0
for i in range(N+1):
for j in range(N+1-i):
for k in range(N+1-i-j):
l = min(N-i-j-k, (W - (w0 * i + (w0+1) * j + (w0+2) * k)) // (w0+3))
if l < 0: continue
if i < len(X[0]) and j < len(X[1]) and k < len(X[2]) and l < len(X[3]):
ma = max(ma, X[0][i] + X[1][j] + X[2][k] + X[3][l])
print(ma) |
s234378300 | p03776 | u595716769 | 1575357580 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 474 | import math
def pcount(n, r):
return math.factorial(n) // (math.factorial(r)* math.factorial(n - r))
n, a, b = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse=True)
T = L[:a]
print(sum(T)/a)
s = 0
Tmin = min(T)
countTminT = T.count(Tmin)
countTminL = L.count(Tmin)
if a == 1 and countTminL == 1:
s = 1
elif countTminT == a:
for i in range(a,b+1):
s += pcount(countTminL, i)
else:
s += pcount(countTminL, countTminT)
print(s) |
s383884854 | p03776 | u383828019 | 1575081646 | Python | PyPy3 (2.4.0) | py | Runtime Error | 165 | 38256 | 851 | import math
nab = [int(x) for x in input().split()]
n = nab[0]
a = nab[1]
b = nab[2]
counts = []
nums = [int(x) for x in input().split()]
means = []
nums.sort(reverse = True)
for i in range(a, b+1):
#means.append(sum(nums[:i])/i)
j = i
while j<n:
if nums[j-1]==nums[j]:
j+=1
else:
break
for k in range(int(math.factorial(j)/(math.factorial(i)*math.factorial(j-i)))):
means.append(sum(nums[:i])/i)
#counts.append(math.comb(j, i))
print(math.factorial(j)/(math.factorial(i)*math.factorial(j-i)))
print(math.factorial(4)/(math.factorial(2)*math.factorial(2)))
print(math.factorial(4))
print(j, i)
print(max(means))
#print(counts[
print(means.count(max(means)))
'''
def C(n, k):
return C(n-1, k-1) + C(n-1, k)
for n in range(MAX_N):
for k in range(MAX_K):
C[n][k] = C[n-1][k-1] + C[n-1][k] |
s349804672 | p03776 | u761529120 | 1574909387 | Python | PyPy3 (2.4.0) | py | Runtime Error | 181 | 38896 | 849 | from operator import mul
from functools import reduce
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
def main():
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
sort_v = sorted(v, reverse=True)
ave = 0
ans = 0
if sort_v[0] == sort_v[A-1]:
cnt = v.count(sort_v[A-1])
ave = sort_v[0]
for i in range(A, min(cnt,B)+1):
ans += cmb(cnt,i)
else:
cnt = v.count(sort_v[A-1])
ind = sort_v.index(sort_v[A-1])
for i in range(ind, A):
ans += cmb(cnt, i)
tmp = 0
for i in range(A):
tmp += sort_v[i]
ave = tmp / A
print(ave)
print(ans)
if __name__ == "__main__":
main() |
s474753341 | p03776 | u682985065 | 1574229604 | Python | Python (3.4.3) | py | Runtime Error | 191 | 14604 | 357 | from scipy.special import comb
n, a, b = map(int,input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
max_avg = sum(v[:a]) / a
min_v = min(v[:a])
ans = 0
for i in range(a, b+1):
if max_avg != sum(v[:i]) / i: break
cnt1 = v[:i].count(min_v)
cnt2 = v.count(min_v)
ans += comb(cnt2, cnt1)
print(max_avg)
print(int(ans)) |
s677631256 | p03776 | u923659712 | 1573758908 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 416 | import math
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
x.reverse()
j=a+1
moto=0
h=0
d=x[a-1]
asd=0
l=x.count(d)
for i in range(a):
moto+=x[i]
if x[i]==x[a-1]:
h+=1
print(moto/a)
if x[0]==x[a-1]:
for i in range(a,b+1):
asd+=math.factorial(l)//(math.factorial(l-i)*math.factorial(i))
print(asd)
else:
print(math.factorial(l)//(math.factorial(l-h)*math.factorial(h))) |
s819198624 | p03776 | u923659712 | 1573758870 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 418 | import math
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
x.reverse()
j=a+1
moto=0
h=0
d=x[a-1]
asd=0
l=x.count(d)
for i in range(a):
moto+=x[i]
if x[i]==x[a-1]:
h+=1
print(moto/a)
if moto/a==x[a-1]:
for i in range(a,b+1):
asd+=math.factorial(l)//(math.factorial(l-i)*math.factorial(i))
print(asd)
else:
print(math.factorial(l)//(math.factorial(l-h)*math.factorial(h))) |
s352702594 | p03776 | u819048695 | 1573405223 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38512 | 917 | n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
ans=0
for i in range(a):
ans+=v[i]
ans/=a
k=a-1
count=1
while k<=n-2:
if v[k]==v[k+1]:
count+=1
k+=1
continue
else:
break
k=a-1
cnt=1
while k>=1:
if v[k]==v[k-1]:
count+=1
cnt+=1
k-=1
continue
else:
break
print(ans)
l=n
for i in range(1,n):
if v[i]==v[0]:
continue
else:
l=i
break
from operator import mul
from functools import reduce
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
print(l)
if l<a:
print(cmb(count,cnt))
if a<=l<=b:
x=0
for i in range(a,l+1):
x+=cmb(l,i)
print(x)
else:
x=0
for i in range(a,b+1):
x+=cmb(l,i)
print(x) |
s414195253 | p03776 | u883574098 | 1571646785 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 38640 | 805 | from collections import Counter
def binomialCoeff(n , k):
C = [0 for i in range(k+1)]
C[0] = 1
for i in range(1,n+1):
j = min(i ,k)
while (j>0):
C[j] = C[j] + C[j-1]
j -= 1
return C[k]
n,x,b=map(int,input().split())
mp={}
a=list(map(int,input().split()))
mp=Counter(a)
a=list(set(a))
a.sort()
ss=0
pq=0
op=0
tot=0
ox=0
for i in range(len(a)-1,-1,-1):
if(ss+mp.get(a[i])>x):
hp=x-ss
oi=mp.get(a[i])
tot=oi
op=hp
pq+=hp*a[i]
ss+=hp
ox=a[i]
break
else:
ss+=mp.get(a[i])
pq+=a[i]*mp.get(a[i])
print(pq/ss)
if(mp.get(ox)==n):
on=0
for i in range(a,b+1):
on=max(on,binomialCoeff(n,i))
print(on)
else:
print(binomialCoeff(tot,op))
|
s018294610 | p03776 | u883574098 | 1571645471 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 611 | from collections import Counter
def binomialCoeff(n , k):
if k==0 or k ==n :
return 1
return binomialCoeff(n-1 , k-1) + binomialCoeff(n-1 , k)
n,x,b=map(int,input().split())
mp={}
a=list(map(int,input().split()))
mp=Counter(a)
a=list(set(a))
a.sort()
ss=0
pq=0
op=0
tot=0
for i in range(len(a)-1,-1,-1):
if(ss+mp.get(a[i])>x):
hp=x-ss
oi=mp.get(a[i])
tot=oi
op=hp
pq+=hp*a[i]
ss+=hp
break
else:
ss+=mp.get(a[i])
pq+=a[i]*mp.get(a[i])
print(pq/a)
if(tot!=0):
print(binomialCoeff(tot,op))
else:
print(1)
|
s953068621 | p03776 | u883574098 | 1571645434 | Python | PyPy3 (2.4.0) | py | Runtime Error | 163 | 38512 | 611 | from collections import Counter
def binomialCoeff(n , k):
if k==0 or k ==n :
return 1
return binomialCoeff(n-1 , k-1) + binomialCoeff(n-1 , k)
n,x,b=map(int,input().split())
mp={}
a=list(map(int,input().split()))
mp=Counter(a)
a=list(set(a))
a.sort()
ss=0
pq=0
op=0
tot=0
for i in range(len(a)-1,-1,-1):
if(ss+mp.get(a[i])>x):
hp=x-ss
oi=mp.get(a[i])
tot=oi
op=hp
pq+=hp*a[i]
ss+=hp
break
else:
ss+=mp.get(a[i])
pq+=a[i]*mp.get(a[i])
print(pq/a)
if(tot!=0):
print(binomialCoeff(tot,op))
else:
print(1)
|
s045676733 | p03776 | u626337957 | 1567723590 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 610 | N, A, B = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort(reverse=True)
least = nums[A-1]
cnt = 1
for i in range(A-1)[::-1]:
if nums[i] == least:
cnt += 1
need = cnt
for i in range(A, B+1):
if nums[i] == least:
cnt += 1
else:
break
nCr = {}
def cmb(n, r):
if r == 0 or r == n: return 1
if r == 1: return n
if (n,r) in nCr: return nCr[(n,r)]
nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
return nCr[(n,r)]
ans = 0
if cnt == N:
print(least)
for i in range(1, N+1):
ans += cmb(N, i)
else:
print(sum(nums[:A])/A)
ans = cmb(cnt, need)
print(ans) |
s614967906 | p03776 | u644778646 | 1567716116 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38640 | 803 | def nck(n, k):
ret = 1
for i in range(min(n - k, k)):
ret *= (n - i)
ret /= (i + 1)
return ret
def main():
n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v = sorted(v, reverse=True)
d = defaultdict(int)
for i in range(n):
d[v[i]] += 1
value = 0
c = 0
t = 0
for i in range(b):
if i < a:
value += v[i]
if i == a - 1:
t = v[i]
for i in range(n):
if v[i] == t:
break
c += d[v[i]]
print(value / a)
ans = 0
if d[v[i]] == n:
for i in range(1, b+1):
if i >= a:
ans += nck(d[t], i)
print(ans)
else:
print(nck(d[t], a - c))
if __name__ == '__main__':
main()
|
s414680401 | p03776 | u606045429 | 1567690075 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 262 | def divisors(N):
U = int(N ** 0.5)
L = [i for i in range(1, U) if N % i == 0]
C = [U] if M % U == 0 else []
R = [N // r for r in reversed(L)]
return L + C + R
N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))
|
s732641947 | p03776 | u017810624 | 1567539327 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 611 | import math
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort()
v.reverse()
if a==n:
print(sum(v)/n)
print(1)
elif v[a-1]!=v[a]:
print(sum(v[0:a])/a)
print(1)
elif v[0]!=v[a-1]:
print(sum(v[0:a])/a)
ct1=0;ct2=0
for i in range(n):
if v[i]==v[a-1]:
ct1+=1
if i<a:
ct2+=1
print(math.factorial(ct1)//(math.factorial(ct1-ct2)*math.factorial(ct2)))
else:
print(sum(v[0:a])/a)
ct1=0;ans=0
for i in range(n):
if v[i]==v[a-1]:
ct1+=1
for i in range(a,b+1):
ans+=math.factorial(ct1)//(math.factorial(ct1-i)*math.factorial(i))
print(ans) |
s839483608 | p03776 | u603253967 | 1565623513 | Python | Python (3.4.3) | py | Runtime Error | 186 | 14400 | 750 | from collections import defaultdict, deque, Counter
import sys
from scipy.special import comb
import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
def main():
N, A, B = [int(a) for a in input().split()]
V = sorted([int(a) for a in input().split()], reverse=True)
s = sum(V[:A]) / A
target = V[A - 1]
if target == V[0]:
co = V.count(target)
t = sum(
comb(co, c, exact=True)
for c in range(A, min(B, co) + 1)
)
print(s)
print(t)
return
c1 = V[:A].count(target)
c2 = V.count(target)
t = comb(c2, c1, exact=True)
print(s)
print(t)
if __name__ == '__main__':
main()
|
s001023287 | p03776 | u838644735 | 1565553363 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38640 | 935 | import math
N, A, B = map(int, input().split())
V = list(map(int, input().split()))
# print(N, A, B, V)
V.sort(reverse=True)
max_list = V[:A]
max_sum = sum(max_list)
print(max_sum / A)
replace = max_list[-1]
num_replace = 0
for v in V:
if v == replace:
num_replace += 1
if num_replace == 1:
print(1)
exit()
num_replace_in_list = 0
for v in max_list:
if v == replace:
num_replace_in_list += 1
if replace * A != max_sum:
ans = 0
for i in range(A, B + 1):
# print(i, num_replace_in_list, num_replace)
if i - A + num_replace_in_list > num_replace:
break
ans += math.factorial(num_replace) // (math.factorial(num_replace - i) * math.factorial(i))
print(ans)
exit()
ans = 0
for i in range(A, B + 1):
if i > num_replace:
break
ans += math.factorial(num_replace) // (math.factorial(num_replace - i) * math.factorial(i))
print(ans)
|
s048959846 | p03776 | u918935103 | 1564891394 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 735 | n,a,b = map(int,input().split())
v = list(map(int,input().split()))
v.sort()
ans1 = 0
for i in range(a):
ans1 = ans1 + v[n-1-i]
ans = ans1/a
if v[n-a] != v[n-a-1]:
print(ans)
print("1")
else:
if v[n-a] < v[n-1]:
count = 1
for i in range(n-a):
if v[i] == v[n-a]:
count = count + 1
print(ans)
print(count)
else:
count0 = 0
for i in range(b):
if v[n-i-1] == v[n-i]:
count0 = count0 + 1
count = 0
c = 1
for x in range(1,a):
c = (c*(n-x+1))//x
for i in range(a,count0+1):
c = c*(50-i+1)//i
count = count + c
print(ans)
print(count) |
s729445418 | p03776 | u532966492 | 1564468638 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38256 | 450 | from statistics import mean
from collections import Counter
n,a,b=map(int,input().split())
v=sorted(list(map(int,input().split())),reverse=True)
avg=mean(v[:a])
print(avg)
p=Counter(v[:a])[v[a]]
q=Counter(v)[v[a]]
def n_func(n):
ans=1
for i in range(1,n+1):ans=(ans*i)
return ans
def nCr(n,r):
return (n_func(n)//n_func(r))//n_func(n-r)
if v[0]==v[a]:
print(sum([nCr(b,a+i) for i in range(0,b-a+1)]))
else:
print(nCr(q,p)) |
s715053431 | p03776 | u761529120 | 1563502903 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 782 | from math import factorial
def combinations_count(n, r):
''' ็ตใฟๅใใ '''
return factorial(n) // (factorial(n - r) * factorial(r))
def max_ave():
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
sort_v = sorted(v, reverse=True)
# ๅนณๅใฎๆๅคงๅคใๆฑใใ
sum_A = 0
for i in range(A):
sum_A += sort_v[i]
max_ave_v = sum_A / A
print(max_ave_v)
# ้ธใณๆนใๆฑใใ
V = sort_v[:A]
num = v.count(min(V))
a = V.count(min(V))
cnt = 0
if max(V) == min(V):
if num == 1:
print(1)
exit()
for i in range(A,B+1):
cnt += combinations_count(num,i)
else:
cnt = combinations_count(num,a)
print(cnt)
max_ave() |
s117627945 | p03776 | u170201762 | 1561740188 | Python | Python (3.4.3) | py | Runtime Error | 190 | 14628 | 538 | from scipy.special import comb
N,A,B = map(int,input().split())
v = list(map(int,input().split()))
v.sort(reverse=True)
ans = 0
if v[A-1] == v[0]:
mean = v[0]
count = 0
for i in range(N):
if v[i] == v[0]:
count += 1
for i in range(A,min(B,count)+1):
ans += comb(count,i,exact=True)
else:
mean = sum(v[:A])/A
count = 0
j = N
for i in range(N):
if v[i] == v[A-1]:
j = min(i,j)
count += 1
ans = comb(count,A-j,exact=True)
print(mean)
print(ans) |
s012008357 | p03776 | u204236873 | 1560572330 | Python | Python (3.4.3) | py | Runtime Error | 153 | 12516 | 1413 | from sys import stdin
import operator as op
import numpy
import math
def combination_table(N):
C = []
for i in range(N+1):
C.append([0] * (N+1))
for i in range(N+1):
for j in range(i+1):
if (j==0 or j==i):
C[i][j] = 1
else:
C[i][j] = C[i-1][j-1]+C[i-1][j]
return C
if __name__ == "__main__":
N, A, B = stdin.readline().split(" ")
N = int(N)
A = int(A)
B = int(B)
V = []
line = stdin.readline().split(" ")
unique_elements = dict()
for e in line:
V.append(int(e))
if not int(e) in unique_elements:
unique_elements[int(e)] = 1
else:
unique_elements[int(e)] += 1
V.sort(reverse=True)
C = combination_table(3)
# find optimal selections between A and B
optimal = [A]
highest_avg = -1
for i in range(A, B+1):
avg = float(sum(V[:i])) / float(i)
if (avg > highest_avg):
highest_avg = avg
optimal = [i] # reset the list
elif (avg == highest_avg):
if not i in optimal:
optimal.append(i)
total = 1
for e in optimal:
# unique elements and count in for optimal value
op_elemements = dict()
for i in range(e):
if V[i] in op_elemements:
op_elemements[V[i]] += 1
else:
op_elemements[V[i]] = 1
# find the sum
for key, value in op_elemements.items():
# print (unique_elements[key], value, C[unique_elements[key]][value])
total = total * C[unique_elements[key]][value]
print ("{:6f}".format(highest_avg))
print (int(total))
|
s500952531 | p03776 | u204236873 | 1560570662 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3688 | 1256 | from sys import stdin
import operator as op
from functools import reduce
def nCr(n, r):
r = min(r, n-r)
numer = reduce(op.mul, range(n, n-r, -1), 1)
denom = reduce(op.mul, range(1, r+1), 1)
return numer / denom
if __name__ == "__main__":
N, A, B = stdin.readline().split(" ")
N = int(N)
A = int(A)
B = int(B)
V = []
line = stdin.readline().split(" ")
unique_elements = dict()
for e in line:
V.append(int(e))
if not int(e) in unique_elements:
unique_elements[int(e)] = 1
else:
unique_elements[int(e)] += 1
V.sort(reverse=True)
# find optimal selections between A and B
optimal = [A]
highest_avg = -1
for i in range(A, B+1):
avg = float(sum(V[:i])) / float(i)
if (avg > highest_avg):
highest_avg = avg
optimal = [i] # reset the list
elif (avg == highest_avg):
if not i in optimal:
optimal.append(i)
total = 1
for e in optimal:
# unique elements and count in for optimal value
op_elemements = dict()
for i in range(e):
if V[i] in op_elemements:
op_elemements[V[i]] += 1
else:
op_elemements[V[i]] = 1
# find the sum
for key, value in op_elemements.items():
total = total * nCr(unique_elements[key], value)
print ("{:6f}".format(highest_avg))
print (int(total))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.