結果

問題 No.21 平均の差
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-02-02 15:55:31
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 350 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 11,860 KB
実行使用メモリ 10,212 KB
最終ジャッジ日時 2023-10-21 18:42:57
合計ジャッジ時間 1,034 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

import math

def diff_mean(i, j):
    m_min = sum(a[:i+1]) / (i + 1)
    m_max = sum(a[j:]) / (N - j)
    
    return math.ceil(m_max - m_min)

N = int(input())
K = int(input())
a = []
for i in range(N):
    a.append(int(input()))

a.sort()

mx = 0
for i in range(N - 2):
    for j in range(i + 2, N):
        mx = max(mx, diff_mean(i, j))

print(mx)
0