結果

問題 No.21 平均の差
ユーザー maimai8maimai8
提出日時 2020-08-12 18:37:47
言語 OCaml
(5.1.0)
結果
WA  
実行時間 -
コード長 568 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 21,580 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 09:09:02
合計ジャッジ時間 795 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

let () =
  let foi = float_of_int in
  Scanf.scanf "%d\n%d\n" @@ fun n k ->
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d\n" @@ fun d -> d in
  let () = Array.fast_sort compare arr in
  let g, a = n / k, n mod k in
  let big =
    (foi (Array.fold_left (+) 0 (Array.sub arr (n-g) g))) /. (foi g) in
  let small =
    if a <> 0 then (foi (Array.fold_left (+) 0 (Array.sub arr 0 (g+1)))) /. (foi (g+1))
    else (foi (Array.fold_left (+) 0 (Array.sub arr 0 g))) /. (foi g) in
  Printf.printf "%.0f %.0f\n" big small;
  Printf.printf "%.0f\n" (ceil (big -. small))
0