#P6702. Mirko's Candy Delivery
Mirko's Candy Delivery
Mirko's Candy Delivery
Mirko needs to deliver ( n ) candies to a candy store. He can use two types of boxes:
- Type 1: holds (3) candies.
- Type 2: holds (5) candies.
Mirko wants to minimize the total number of boxes used. For example, if ( n = 18 ), one option is to use six Type 1 boxes ((6 \times 3 = 18)); however, the optimal strategy is to use three Type 2 boxes and one Type 1 box ((3 \times 5 + 1 \times 3 = 18)), totaling 4 boxes.
Your task is to help Mirko find the minimum number of boxes required to exactly pack ( n ) candies. If it is not possible to pack exactly ( n ) candies with these boxes, output (-1).
inputFormat
The input consists of a single integer ( n ) ((1 \le n \le 5000)), representing the number of candies.
outputFormat
Output a single integer representing the minimum number of boxes required to exactly pack ( n ) candies. If no valid combination exists, output (-1).
sample
18
4