結果
| 問題 | No.275 中央値を求めよ |
| コンテスト | |
| ユーザー |
nohopen
|
| 提出日時 | 2019-02-11 09:21:50 |
| 言語 | Scheme (Gauche-0.9.15) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 1,000 ms |
| コード長 | 423 bytes |
| 記録 | |
| コンパイル時間 | 118 ms |
| コンパイル使用メモリ | 7,840 KB |
| 実行使用メモリ | 33,408 KB |
| 最終ジャッジ日時 | 2026-04-01 15:16:00 |
| 合計ジャッジ時間 | 1,987 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
(define (median str)
(let* ((sorted (sort str)))
(if (= (modulo (length str) 2) 1)
(list-ref sorted (quotient (length str) 2))
(/. (+ (list-ref sorted (quotient (length str) 2))
(list-ref sorted (- (quotient (length str) 2) 1))) 2))))
(define (create-list n)
(if (= n 0) '()
(cons (read) (create-list (- n 1)))))
(define (main args)
(print (median (create-list (read)))) 0)
nohopen