結果

問題 No.21 平均の差
ユーザー sue_charosue_charo
提出日時 2017-08-12 01:15:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 882 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-21 00:28:47
合計ジャッジ時間 1,060 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 36 ms
10,752 KB
testcase_02 AC 52 ms
10,880 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 29 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 AC 52 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
from itertools import combinations
import math

def II(): return int(input())
def ILI(): return list(map(int, input().split()))
N = II()
K = II()
n = [II() for __ in range(N)]

sum_n = sum(n)
s_n = set(n)
ans = -1
for i in range(1, N - 2):
    for comb_1 in combinations(n, i):
        s_comb_1 = set(comb_1)
        sum_comb_1 = sum(comb_1)
        ave_comb_1 = sum_comb_1 / i
        s_others = s_n - s_comb_1
        for j in range(1, N - i - 2):
            for comb_2 in combinations(s_others, j):
                sum_comb_2 = sum(comb_2)
                ave_comb_2 = sum_comb_2 / j
                sum_comb_3 = sum_n - sum_comb_1 - sum_comb_2
                ave_comb_3 = sum_comb_3 / (N - i - j)
                dif = math.floor(max(ave_comb_1, ave_comb_2, ave_comb_3) - min(ave_comb_1, ave_comb_2, ave_comb_3))
                ans = max(ans, dif)

print(ans)
0