結果

問題 No.21 平均の差
ユーザー zimphazimpha
提出日時 2017-12-09 02:10:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 5,000 ms
コード長 428 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 78,532 KB
最終ジャッジ日時 2023-08-20 00:20:05
合計ジャッジ時間 2,522 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,264 KB
testcase_01 AC 130 ms
77,844 KB
testcase_02 AC 158 ms
78,532 KB
testcase_03 AC 72 ms
71,268 KB
testcase_04 AC 94 ms
76,316 KB
testcase_05 AC 71 ms
71,348 KB
testcase_06 AC 72 ms
71,160 KB
testcase_07 AC 83 ms
76,788 KB
testcase_08 AC 77 ms
75,904 KB
testcase_09 AC 120 ms
77,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
k = int(input())
a = [int(input()) for i in range(n)]
group = [[] for i in range(k)]
def search(d, m):
  if d == n:
    if m == k:
      avg = [sum(x) / len(x) for x in group]
      return max(avg) - min(avg)
    else:
      return 0
  ret = 0
  for i in range(min(m + 1, k)):
    group[i].append(a[d])
    ret = max(ret, search(d + 1, max(m, i + 1)))
    group[i].pop(-1)
  return ret

print(int(search(0, 0)))
0