結果
問題 | No.564 背の順 |
ユーザー | ducktail |
提出日時 | 2018-01-01 20:20:55 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 554 bytes |
コンパイル時間 | 19,029 ms |
コンパイル使用メモリ | 162,152 KB |
実行使用メモリ | 7,672 KB |
最終ジャッジ日時 | 2023-08-24 15:42:39 |
合計ジャッジ時間 | 12,224 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,212 KB |
testcase_01 | AC | 2 ms
7,100 KB |
testcase_02 | AC | 3 ms
7,644 KB |
testcase_03 | AC | 2 ms
7,400 KB |
testcase_04 | AC | 3 ms
7,204 KB |
testcase_05 | AC | 3 ms
7,672 KB |
testcase_06 | AC | 3 ms
7,584 KB |
testcase_07 | AC | 3 ms
7,316 KB |
testcase_08 | AC | 3 ms
7,540 KB |
testcase_09 | AC | 2 ms
7,152 KB |
testcase_10 | AC | 3 ms
7,204 KB |
testcase_11 | AC | 3 ms
7,236 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Control.Applicative ((<$>)) import Control.Monad import Data.List main :: IO () main = do [h, n] <- getl $ map read . words solve h <$> replicateM (n - 1) (getl read) >>= putStrLn solve :: Int -> [Int] -> String solve h hs = ordinal . (+1) . length . takeWhile (> h) . sortBy (flip compare) $ hs where ordinal x = case x `mod` 10 of 1 -> show x ++ "st" 2 -> show x ++ "nd" 3 -> show x ++ "rd" _ -> show x ++ "th" getl :: (String -> a) -> IO a getl f = f <$> getLine