It's Rar the Cat's birthday! To celebrate this occasion, his group of N cats are going to a restaurant to have their lunch today! Yay! This restaurant has M different main meals and S different side dishes. Today, the cats have decided to ask Mewy, one of the cats, to order their meals for them. Each of the N cats must get one set (1 main meal + 1 side dish), although they don't care which one they get.
Mewy, being a very nice cat, wants to be fair to his cat friends and let them pay as little as possible. Help Mewy by optimally pairing the main meals and side dishes such that the cost of the most expensive set is minimised.
The first line of input will contain three integers, N, M and S.
The second line of input contains M integers, with the ith integer representing the cost of the ith main meal.
The third line of input contains S integers, with the ith integer representing the cost of the ith side dish.
Your output should contain one integer, the minimum possible cost of the most expensive set.
Your output should be terminated with a newline.
1 <= N <= 10 000
N <= M <= 100 000
N <= S <= 100 000
3 4 4 1 3 4 7 4 1 2 5
5
The best way Mewy can pair the sets is by buying:
Subtask | Score |
---|---|
1 | 100 |
2 | 0 |