結果

問題 No.275 中央値を求めよ
ユーザー Yuzu Mashiro
提出日時 2021-04-03 16:49:45
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 39 ms / 1,000 ms
コード長 348 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-12-25 01:17:26
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

(define n (string->number (read-line)))
(define as (sort (map string->number (string-split (read-line) " "))))

(print (cond ((zero? (mod n 2))
              (let* ((ptr (/ n 2))
                     (a (ref as (- ptr 1)))
                     (b (ref as ptr)))
               (/ (+ a b) 2)))
             (else (ref as (- (ceiling (/ n 2)) 1)))))
0