Skip to content

Instantly share code, notes, and snippets.

@l4u
Created April 18, 2014 10:43
Show Gist options
  • Save l4u/11037091 to your computer and use it in GitHub Desktop.
Save l4u/11037091 to your computer and use it in GitHub Desktop.
import Debug.Trace
import Control.Monad
import Data.List
getInt::IO Integer
getInt = do
s <- getLine
return (read s)
pro :: [Integer] -> Integer -> Integer -> Integer -> Integer
pro (l:ls) m s c
| s >= m = c
| otherwise = pro ls m (s+l) c+1
pro [] _ _ _ = -1
main :: IO ()
main = do
_ <- getInt
l <- fmap ((map read) . words) getLine :: IO [Integer]
let sortL = sortBy (flip compare) l
print sortL
t <- liftM read getLine
replicateM_ t (do
i <- getInt
print $ (pro sortL i 0 0)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment