結果

問題 No.21 平均の差
ユーザー gorugo30gorugo30
提出日時 2021-02-22 19:14:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 5,000 ms
コード長 661 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 75,852 KB
最終ジャッジ日時 2023-10-21 13:56:14
合計ジャッジ時間 1,771 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,824 KB
testcase_01 AC 81 ms
75,852 KB
testcase_02 AC 80 ms
75,844 KB
testcase_03 AC 71 ms
75,840 KB
testcase_04 AC 80 ms
75,828 KB
testcase_05 AC 76 ms
75,848 KB
testcase_06 AC 78 ms
75,848 KB
testcase_07 AC 78 ms
75,820 KB
testcase_08 AC 79 ms
75,820 KB
testcase_09 AC 81 ms
75,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ans = 0
for bit in range(3 ** 9):
    grp = [0] * 3
    grplen = [0] * 3
    for i in range(N):
        j = (bit // (3 ** i)) % 3
        grp[j] += n[i]
        grplen[j] += 1
    if min(grplen) == 0:
        continue
    otherlen = [1] * N
    lenprod = 1
    for i in range(3):
        lenprod *= grplen[i]
        for j in range(3):
            if i == j:
                continue
            otherlen[i] *= grplen[j]
    if lenprod == 0:
        continue
    for i in range(3):
        grp[i] *= otherlen[i]
    ans = max(ans, (max(grp) - min(grp) + lenprod - 1) // lenprod)
print(ans)
0