結果

問題 No.21 平均の差
ユーザー mlihua09mlihua09
提出日時 2020-08-26 10:21:29
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 80 ms / 5,000 ms
コード長 548 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 71,584 KB
最終ジャッジ日時 2023-08-06 22:01:31
合計ジャッジ時間 1,979 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,476 KB
testcase_01 AC 76 ms
71,484 KB
testcase_02 AC 80 ms
71,488 KB
testcase_03 AC 76 ms
71,424 KB
testcase_04 AC 75 ms
71,568 KB
testcase_05 AC 74 ms
71,416 KB
testcase_06 AC 75 ms
71,420 KB
testcase_07 AC 75 ms
71,584 KB
testcase_08 AC 75 ms
71,424 KB
testcase_09 AC 74 ms
71,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations

N = int(input())

K = int(input())

n = [int(input()) for i in range(N)]

n.sort()

ans = 0

for k in combinations(range(1, N), r=K - 1):
    
    x = 0
    
    M = 0
    
    m = 1000
    
    for i in k:
        
        Average = sum(n[x:i]) / (i - x)
        
        m = min(Average, m)
        
        M = max(Average, M)
        
        x = i
        
    Average = sum(n[x:]) / (N - x)
    
    m = min(Average, m)
    
    
    M = max(Average, M)
    
    ans = max(ans, int(M - m))
    
print(ans)
0