-- Given two sequences a1, a2.. an (ai is the profit per click of the i-th ad) and b1, b2, . . . , bn (bi is
-- the average number of clicks per day of the i-th slot), we need to partition them into n pairs (ai, bi))
-- such that the sum of their products is maximized.

main :: IO ()
main =
  hSetBuffering stdin NoBuffering >>= \_ ->
  nextNum >>= \n ->
  allHours n >>= \h ->
  let solved = solve h
      size = length solved
      print' = intercalate " " . map show
  in  (putStrLn $ show size) >>= \_ ->
      putStrLn $ print' solved
main :: IO ()
main =
  hSetBuffering stdin NoBuffering >>= \_ ->
  nextNum >>= \n ->
  allHours n >>= \h ->
  let solved = solve h
      size = length solved
      print' = intercalate " " . map show
  in  (putStrLn $ show size) >>= \_ ->
      putStrLn $ print' solved
main =
  hSetBuffering stdin NoBuffering >>= \_ ->
  nextNum >>= \n ->
  allHours n >>= \h ->
  let solved = solve h
      size = length solved
      print' = intercalate " " . map show
  in  (putStrLn $ show size) >>= \_ ->
      putStrLn $ print' solved