結果
| 問題 | No.275 中央値を求めよ |
| コンテスト | |
| ユーザー |
shikatsusan
|
| 提出日時 | 2016-05-12 13:52:01 |
| 言語 | Haskell (9.14.1) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 1,000 ms |
| コード長 | 290 bytes |
| 記録 | |
| コンパイル時間 | 950 ms |
| コンパイル使用メモリ | 199,508 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2026-03-11 03:54:19 |
| 合計ジャッジ時間 | 2,188 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:7:27: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, but defined in GHC.Internal.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
|
7 | |odd (length xs) = head . drop centerId . sort $ xs
| ^^^^
[2 of 2] Linking a.out
ソースコード
import Data.List
main::IO()
main = do
getLine
xs<-fmap (fmap read . words) getLine
let exe xs
|odd (length xs) = head . drop centerId . sort $ xs
|otherwise =(/2) . sum . take 2 . drop (centerId -1). sort $ xs
where centerId =length xs `div` 2
print . exe $ xs
shikatsusan