結果
| 問題 | No.564 背の順 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-01-01 20:20:55 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 554 bytes | 
| コンパイル時間 | 7,988 ms | 
| コンパイル使用メモリ | 171,392 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-22 23:52:36 | 
| 合計ジャッジ時間 | 8,706 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/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
            
            
            
        