結果

問題 No.21 平均の差
ユーザー kohei2019kohei2019
提出日時 2021-02-10 10:58:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 592 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 79,632 KB
最終ジャッジ日時 2023-09-22 04:13:05
合計ジャッジ時間 2,018 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
71,656 KB
testcase_01 AC 133 ms
77,924 KB
testcase_02 WA -
testcase_03 AC 85 ms
71,588 KB
testcase_04 AC 85 ms
71,340 KB
testcase_05 AC 84 ms
71,588 KB
testcase_06 AC 84 ms
71,828 KB
testcase_07 WA -
testcase_08 AC 86 ms
71,592 KB
testcase_09 AC 89 ms
71,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
import sys
import copy
import math
N = int(input())
K = int(input())
lsn = [int(input()) for i in range(N)]
if N==K:
    print(max(lsn)-min(lsn))
    sys.exit()
group = [[lsn[i]] for i in range(K)]
lsk = lsn[K:]
lsp = itertools.product(range(K),repeat=N-K)
ans = 0
for p in lsp:
    lsg2 = copy.deepcopy(group)
    for i in range(N-K):
        lsg2[p[i]].append(lsk[i])
    maxa = 0
    mina = 10000
    for i in range(K):
        maxa = max(maxa,sum(lsg2[i])/len(lsg2[i]))
        mina = min(mina,sum(lsg2[i])/len(lsg2[i]))
    ans = max(ans,math.ceil(maxa-mina))
print(ans)
0