結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2019-02-11 09:28:16 |
言語 | Scheme (Gauche-0.9.15) |
結果 |
AC
|
実行時間 | 28 ms / 1,000 ms |
コード長 | 474 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 7,072 KB |
実行使用メモリ | 16,512 KB |
最終ジャッジ日時 | 2024-07-18 00:13:47 |
合計ジャッジ時間 | 2,722 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
(define (median str) (let* ((sorted (sort str)) ;ソートされた数列 (len (length str)) ;数列の長さ (mid (quotient len 2)));数列の中央 (if (= (modulo len 2) 1) (list-ref sorted mid) (/. (+ (list-ref sorted mid) (list-ref sorted (- mid 1))) 2)))) (define (create-list n) (if (= n 0) '() (cons (read) (create-list (- n 1))))) (define (main args) (print (median (create-list (read)))) 0)