結果
| 問題 | No.275 中央値を求めよ |
| コンテスト | |
| ユーザー |
nohopen
|
| 提出日時 | 2019-02-11 09:21:50 |
| 言語 | Scheme (Gauche-0.9.15) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 1,000 ms |
| コード長 | 423 bytes |
| コンパイル時間 | 207 ms |
| コンパイル使用メモリ | 6,812 KB |
| 実行使用メモリ | 16,512 KB |
| 最終ジャッジ日時 | 2024-07-18 00:03:13 |
| 合計ジャッジ時間 | 2,213 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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