結果

問題 No.1130 Grid Numbers
ユーザー nnsnico
提出日時 2020-08-02 20:40:09
言語 Haskell
(9.10.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 9,157 ms
コンパイル使用メモリ 180,416 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 07:27:07
合計ジャッジ時間 9,577 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

module Main where

import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.String
import Data.List
import Data.Maybe
import Control.Monad

type Width = Int
type Height = Int
type Rectangle = (Width, Height)
type Target = [Int]
type OutputValue = [[BS.ByteString]]
type InitialValue = OutputValue

main :: IO ()
main = do
  [h, w] <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  xn <- replicateM h $ map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  flatten <- return . sort $ concat xn
  let r = toOutputValue (w, h) flatten []
  mapM_ (putStrLn . BS.unpack . BS.unwords) r

toOutputValue :: Rectangle -> Target -> InitialValue -> OutputValue
toOutputValue (n, count) ls init
  | count > 0 = toOutputValue (n, count - 1) (drop n ls) (map (BS.pack . show) (take n ls) : init)
  | otherwise = reverse init
0