All pastes #2065645 Raw Edit

Miscellany

public text v1 · immutable
#2065645 ·published 2011-05-20 12:52 UTC
rendered paste body

import Data.List
import System.Environment
import System.IO
import Text.Printf
import Data.Bits
import Debug.Trace
import Control.Applicative


present :: (Int, Maybe Int) -> IO ()
present (idx, Nothing) = printf "Case #%d: NO\n" idx
present (idx, Just result) = printf "Case #%d: %d\n" idx result

main = (enumFromTo 1 . read <$> getLine) >>= mapM_ main'
        where main' caseno = do
                _ <- getLine -- drop the # count
                soln <- optimal . map read . words <$> getLine
                present (caseno,soln)