結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-04 23:43:23 |
| 言語 | OCaml (5.2.1) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 430 bytes |
| コンパイル時間 | 339 ms |
| コンパイル使用メモリ | 20,852 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-09 00:00:06 |
| 合計ジャッジ時間 | 1,838 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
let solve n a_lst =
if n mod 2 = 1 then
List.nth a_lst (n / 2)
else
let a1 = List.nth a_lst (n / 2 - 1)
and a2 = List.nth a_lst (n / 2) in
(a1 +. a2) /. 2.
let () =
let n = read_line () |> int_of_string
and a_lst = read_line ()
|> Str.split (Str.regexp_string " ")
|> List.map float_of_string
|> List.sort compare
in
solve n a_lst
|> Printf.printf "%0.1f\n"