結果

問題 No.21 平均の差
ユーザー mlihua09mlihua09
提出日時 2020-08-26 10:20:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 539 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 71,564 KB
最終ジャッジ日時 2023-08-06 22:01:29
合計ジャッジ時間 2,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,460 KB
testcase_01 AC 74 ms
71,392 KB
testcase_02 WA -
testcase_03 AC 73 ms
71,320 KB
testcase_04 AC 73 ms
71,432 KB
testcase_05 AC 74 ms
71,416 KB
testcase_06 AC 74 ms
71,500 KB
testcase_07 AC 75 ms
71,412 KB
testcase_08 AC 76 ms
71,192 KB
testcase_09 AC 75 ms
71,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


from itertools import combinations

N = int(input())

K = int(input())

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

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