Electronics Shop

Published: 01 January 1970
on channel: Shital Luitel
65
1

Monica wants to buy exactly one keyboard and one USB drive from her favorite electronics store. The store sells n different brands of keyboards and n different brands of USB drives. Monica has exactly dollars to spend, and she wants to spend as much of it as possible (i.e., the total cost of her purchase must be maximal).

Given the price lists for the store's keyboards and USB drives, find and print the amount money Monica will spend. If she doesn't have enough money to buy one keyboard and one USB drive, print -1 instead.

Note: She will never buy more than one keyboard and one USB drive even if she has the leftover money to do so.

Input Format

The first line contains three space-separated integers describing the respective values of s (the amount of money Monica has), n (the number of keyboard brands) and m (the number of USB drive brands).
The second line contains space-separated integers denoting the prices of each keyboard brand.
The third line contains space-separated integers denoting the prices of each USB drive brand.


On this page of the site you can watch the video online Electronics Shop with a duration of hours minute second in good quality, which was uploaded by the user Shital Luitel 01 January 1970, share the link with friends and acquaintances, this video has already been watched 65 times on youtube and it was liked by 1 viewers. Enjoy your viewing!