結果

問題 No.275 中央値を求めよ
ユーザー Haar
提出日時 2016-03-16 08:57:56
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 247 bytes
コンパイル時間 6,857 ms
コンパイル使用メモリ 176,000 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-10-01 20:11:56
合計ジャッジ時間 8,349 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 28 WA * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:4:1: warning: [GHC-94817] [-Wtabs]
    Tab character found here, and in five further locations.
    Suggested fix: Please use spaces instead.
  |
4 |                   | otherwise    = xs!!(div l 2)
  | ^^^^^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List
median :: [Integer] -> Integer
median xs | mod l 2 == 0 = (xs!!(div l 2) + xs!!((div l 2)-1))`div`2
		  | otherwise    = xs!!(div l 2)
		where l = length xs

main = do
	getLine
	getLine >>= print . median . sort . map read . words
0