atcoder#HITACHI2020B. Nice Shopping
Nice Shopping
Score : points
Problem Statement
You are visiting a large electronics store to buy a refrigerator and a microwave.
The store sells kinds of refrigerators and kinds of microwaves. The -th refrigerator ( ) is sold at yen (the currency of Japan), and the -th microwave ( ) is sold at yen.
You have discount tickets. With the -th ticket ( ), you can get a discount of yen from the total price when buying the -th refrigerator and the -th microwave together. Only one ticket can be used at a time.
You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 3 1
3 3
3 3 3
1 2 1
5
With the ticket, you can get the -st refrigerator and the -nd microwave for yen.
1 1 2
10
10
1 1 5
1 1 10
10
Note that you cannot use more than one ticket at a time.
2 2 1
3 5
3 5
2 2 2
6
You can get the -st refrigerator and the -st microwave for yen, which is the minimum amount to pay in this case. Note that using a ticket is optional.