-
-
Save gorlum0/1153330 to your computer and use it in GitHub Desktop.
codeforces - 37 - A (hs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS_GHC -O2 -XNoMonomorphismRestriction #-} | |
{-# LANGUAGE BangPatterns #-} | |
{-(c) gorlum0 [at] gmail.com-} | |
import Text.Printf | |
import Data.List (group, sort, maximumBy) | |
import Data.Ord (comparing) | |
towers bs = (h, t) | |
where | |
bs' = group . sort $ bs | |
h = length $ maximumBy (comparing length) bs' | |
t = length bs' | |
body [] = [] | |
body (n:xs) = towers bs : body xs' | |
where | |
n' = read n | |
(bs, xs') = splitAt n' xs | |
fmt :: (Int, Int) -> String | |
fmt (h, t) = printf "%d %d" h t | |
main = do | |
ws <- words `fmap` getContents | |
mapM_ (putStrLn . fmt) (body ws) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment