Problem P
Maximum Rent
Languages
en
ja
Yan and Fen have just accepted jobs in TechValley California allowing them to pursue their childhood dream of renting the most expensive apartment in the area.
Yan and Fen have decided that the rent of an apartment
denoted
Fortunately for the pair, TechValley California has no
shortage of expensive apartments for rent. Unfortunately, there
are some specific constraints on the apartment and the contents
of the apartment that Yan and Fen must follow. First the square
footage of the apartment and the number of smart bulbs must
both be greater than or equal to
Secondly, the square footage of the apartment plus the
number of smartbulbs cannot exceed a specific
Lastly, since both Yan and Fen need lots of outlets in their
apartment to support all their electronics they will only look
at apartments that have exactly
Find the maximum rent of an apartment
Input
The input consists of a single test case with two lines. The
test case starts with two integers
Output
Output a single line with the maximum value of
Sample Input 1 | Sample Output 1 |
---|---|
3 1 12 16 |
34 |
Sample Input 2 | Sample Output 2 |
---|---|
0 3 8 12 |
12 |