import Control.Applicative import Control.Monad import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B import Data.List import Data.Char (isSpace) main :: IO () main = do [n, k] <- f unwords <$> map show <$> solve k <$> f >>= putStrLn where f = readil B.readInt <$> B.getLine solve :: Int -> [Int] -> [Int] solve k as = [length l, k - last l] where l = takeWhile (<= k) $ scanl1 (+) $ sort as readil :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a] readil f = unfoldr $ f . B.dropWhile isSpace