<$> B.getLine :: IO [Int] xss <- map (map readi . B.words) <$> replicateM n B.getLine :: IO [[Int]] let f [x,y] = (fromIntegral x % fromIntegral y, y) :: (Rational, Int) yss = map f xss yss' = sortBy (comparing Down) yss ans = fromRational $ knapzak w 0 yss' :: Double printf "%.9f\n" $ ans knapzak :: Int -> Rational -> [(Rational, Int)] -> Rational knapzak w r [] = r knapzak w r (x:ps) | w == 0 = r | otherwise = knapzak w2 (r+r2) ps where (r2, w2) = g w x しかし皆さんは大学院の授業、 宣言的プログラミングを履修していないので Haskellで書かれたコードを読むことができません 🥺
in combinatory logic, Transactions of the American Mathematical Society, 146, 29-60 (1969) • MilnerRobin:A theory of type polymorphism in programming, Journal of Computer and System Sciences, 17(3), 348-375 (1978)