結果

問題 No.21 平均の差
ユーザー kohei2019kohei2019
提出日時 2021-02-10 11:14:36
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 78,412 KB
最終ジャッジ日時 2023-09-22 04:33:07
合計ジャッジ時間 2,662 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,604 KB
testcase_01 AC 99 ms
76,300 KB
testcase_02 WA -
testcase_03 AC 97 ms
71,528 KB
testcase_04 AC 95 ms
71,548 KB
testcase_05 AC 99 ms
71,536 KB
testcase_06 AC 96 ms
71,808 KB
testcase_07 AC 128 ms
77,424 KB
testcase_08 AC 94 ms
71,644 KB
testcase_09 AC 152 ms
78,412 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()
lsp = itertools.combinations_with_replacement(range(K),N)
ans = 0
for p in lsp:
    lsg2 = [[] for i in range(K)]
    for i in range(N):
        lsg2[p[i]].append(lsn[i])
    maxa = 0
    mina = 10000
    f = True
    for i in range(K):
        if len(lsg2[i]) == 0:
            f= False
            break
        maxa = max(maxa,sum(lsg2[i])/len(lsg2[i]))
        mina = min(mina,sum(lsg2[i])/len(lsg2[i]))
    if f:
        ans = max(ans,math.ceil(maxa-mina))
print(ans)
0