#CCBCHBAHAI0000091. Electronics Shop
Electronics Shop
Electronics Shop
Source: HackerRank
Version: Phuoc Hung OJ Extended
Problem
Given budget , keyboard prices , and USB-drive prices , buy exactly one item from each list.
Find
If no valid pair exists, print .
Input
The first line contains , , and . The next two lines contain keyboard and USB-drive prices.
Output
Print the maximum affordable total, or if no pair can be bought.
Subtask
Subtask 1 (20 points): , .
Subtask 2 (30 points): , .
Subtask 3 (50 points): , .
Example
Input
10 2 3
3 1
5 2 8
Output
9
Explanation
The result follows directly from the mathematical definition above.