AtCoder Beginner Contest 057

Submission #10165493

Source codeソースコード

from collections import Counter
import math
n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
MAX = sum(v[:a]) / a
print(MAX)

c = Counter(v)
average_nums = []
for i in range(a, b + 1):
    t = sum(v[:i]) / i
    if t >= MAX:
        average_nums.append(Counter(v[:i]))

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

ans = 0
for num in average_nums:
    multi = 1
    for k, v in num.items():
        multi = multi * nCr(c[k], v)
    ans += multi
print(ans)

Submission

Task問題 D - Maximum Average Sets
User nameユーザ名 tiruka
Created time投稿日時
Language言語 PyPy3 (2.4.0)
Status状態 AC
Score得点 400
Source lengthソースコード長 570 Byte
File nameファイル名
Exec time実行時間 183 ms
Memory usageメモリ使用量 39664 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt
All 400 / 400 sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt,subtask_1_1.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt,subtask_1_14.txt,subtask_1_15.txt,subtask_1_2.txt,subtask_1_3.txt,subtask_1_4.txt,subtask_1_5.txt,subtask_1_6.txt,subtask_1_7.txt,subtask_1_8.txt,subtask_1_9.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 171 ms 38896 KB
sample_02.txt AC 168 ms 38512 KB
sample_03.txt AC 166 ms 38256 KB
sample_04.txt AC 183 ms 39664 KB
subtask_1_1.txt AC 170 ms 38256 KB
subtask_1_10.txt AC 168 ms 38512 KB
subtask_1_11.txt AC 176 ms 38768 KB
subtask_1_12.txt AC 171 ms 38640 KB
subtask_1_13.txt AC 165 ms 38256 KB
subtask_1_14.txt AC 172 ms 38256 KB
subtask_1_15.txt AC 167 ms 38256 KB
subtask_1_2.txt AC 165 ms 38256 KB
subtask_1_3.txt AC 169 ms 38256 KB
subtask_1_4.txt AC 167 ms 38256 KB
subtask_1_5.txt AC 166 ms 38512 KB
subtask_1_6.txt AC 172 ms 38384 KB
subtask_1_7.txt AC 163 ms 38256 KB
subtask_1_8.txt AC 166 ms 38384 KB
subtask_1_9.txt AC 167 ms 38256 KB