結果
| 問題 |
No.275 中央値を求めよ
|
| ユーザー |
Common Lisp
|
| 提出日時 | 2024-10-09 12:34:30 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 1,000 ms |
| コード長 | 296 bytes |
| コンパイル時間 | 155 ms |
| コンパイル使用メモリ | 28,032 KB |
| 実行使用メモリ | 21,888 KB |
| 最終ジャッジ日時 | 2024-10-09 12:34:33 |
| 合計ジャッジ時間 | 1,729 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 09 OCT 2024 12:34:30 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.008
ソースコード
; 中央値を求める
(defun main ()
(let* ((n (read))
(m (floor (1- n) 2))
(xs (sort (loop repeat n collect (read)) #'<))
(ans (if (evenp n)
(/ (+ (elt xs m) (elt xs (1+ m))) 2d0)
(elt xs m))))
(format t "~f~%" ans)))
(main)
Common Lisp