Problem L
Abby's Absolutes
Abby has offered to buy you some apples. However, she is very absolute about things.
You may ask her to buy a certain number of apples, but she
may buy more apples if she figures that you want a lot of
apples, or just buy one apple if she figures that you do not
want very many apples. So, if the number of apples you want is
closer to Abby’s upper threshold than it is to
You want to figure out the total number of apples Abby will buy for you after she takes one or more trips to the grocery store.
Input
The input will consist of two lines.
The first line will contain two space-separated integers.
The first integer
The second line will contain
Output
Output
Sample Input 1 | Sample Output 1 |
---|---|
5 5 1 2 3 4 5 |
1 1 1 5 5 |
Sample Input 2 | Sample Output 2 |
---|---|
6 8 1 5 4 2 5 4 6 4 |
1 6 6 1 6 6 6 6 |