import Data.List

main :: IO ()
main = do
    [_, _, k] <- map read . words <$> getLine
    as <- map read . words <$> getLine
    bs <- map read . words <$> getLine
    let as' = takeWhile (\x -> snd x <= k) [(n, sum (take n as)) | n <- [0..length as]]
        ads = [k - n | (_ , n) <- as']
        bs' = [last $ takeWhile (\b -> sum (take b bs) <= x) [m | m <- [0..length bs]] | x <- ads]
        tmp = zipWith (\(a, x) b -> a + b) as' bs'
        res = maximum tmp
    putStrLn $ show res