結果

問題 No.21 平均の差
ユーザー apierceapierce
提出日時 2022-11-02 02:30:33
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 569 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 11,436 KB
実行使用メモリ 47,148 KB
最終ジャッジ日時 2023-09-23 13:25:58
合計ジャッジ時間 10,954 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
47,148 KB
testcase_01 AC 3,993 ms
26,540 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
k = gets.to_i
a = n.times.map{gets.to_f}
ans = []

a.permutation.each do |arr|
    (0..(n-2)).to_a.combination(k-1).each do |comb|
        cnd = []
        (k-1).times do |i|
            if i == 0
                cnd << (arr[0..(comb[i])].sum / (comb[i] - 0 + 1)).ceil
            else
                cnd << (arr[(comb[i-1]+1)..comb[i]].sum / (comb[i] - comb[i-1])).ceil
                cnd << ((arr[(comb[i]+1)..].sum) / arr[(comb[i]+1)..].count).ceil  if i == k-2
            end
        end
        ans << cnd.max - cnd.min
    end
end

puts ans.max

0