-- 解説を参照 import Data.List rInt :: String -> Int rInt = read binarySearch :: [Int] -> Int -> Int -> Int binarySearch rgb low high | high - low == 1 = low | check = binarySearch rgb mid high | otherwise = binarySearch rgb low mid where mid = (low + high) `div` 2 check = (foldr chengeNum 0 (map (\x -> x - mid) rgb)) >= 0 chengeNum x y | x > 0 = x `div` 2 + y | otherwise = x + y main = do stones <- map rInt . words <$> getLine print $ binarySearch stones 0 (2^24)