結果
| 問題 |
No.21 平均の差
|
| コンテスト | |
| ユーザー |
_KingdomOfMoray
|
| 提出日時 | 2019-11-30 19:22:25 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 792 bytes |
| コンパイル時間 | 245 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-11-21 03:28:42 |
| 合計ジャッジ時間 | 996 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 1 |
ソースコード
import itertools
import math
n = int(input())
k = int(input())
idxlist = [0] * (n-1)
for i in range(len(idxlist)):
idxlist[i] = i
list_a = [int(input()) for i in range(n)] #n elements
# listの要素の間に縦線を入れるときの組み合わせ
# 組み合わせ数: n-1_C_k-1
# k = 4
combtuple = list(itertools.combinations(idxlist, k-1))
# listの両端に縦線を入れる
res = []
for curtuple in combtuple:
curlist = list(curtuple)
# print(curlist)
curlist.insert(0, -1)
curlist.insert(len(curlist), n)
# print(curlist)
avrlist = []
for j in range(k):
listb = list_a[curlist[j]+1 : curlist[j+1]+1]
avrlist.append(sum(listb) / len(listb))
res.append(math.ceil(max(avrlist)-min(avrlist)))
avrlist.clear()
print(max(res))
_KingdomOfMoray