import qualified Data.List as L data Input = Input { yukiHotelFee :: Int , otherHotelFee :: Int , dataCount :: Int , reservationNumbers :: [Int] } deriving Show createInput :: String -> Input createInput inputString = Input { yukiHotelFee = yFee, otherHotelFee = oFee, dataCount = count, reservationNumbers = numbers} where lineData = lines inputString yFee = read $ lineData !! 0 oFee = read $ lineData !! 1 count = read $ lineData !! 2 numbers = map read . drop 3 $ lineData calcurate :: Input -> Int calcurate input = duplicateCount * losses where duplicateCount = (length $ reservationNumbers input) - (length . L.nub $ reservationNumbers input) losses = yukiHotelFee input + otherHotelFee input process :: String -> Int process = calcurate . createInput main :: IO () main = do inputString <- getContents print $ process inputString