Moving Company
InterviewTime limit2sMemory limit512 MB
Given counts of items weighing 1 to 5 kg, find the minimum number of 5 kg baskets needed to pack them all.
- Level
Medium6 of 10
- Topics
- Greedy, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Alex runs a moving company. In the house he must move today there are items weighing 1kg, items weighing 2kg, items weighing 3kg, items weighing 4kg, and items weighing 5kg.
To carry the items he must put them into baskets, and a basket can hold at most 5kg. Alex wants to minimize the number of baskets needed to hold all the items.
The total weight of the items in one basket cannot exceed 5kg.
Given the weights of the items, write a program that finds the minimum number of baskets needed to hold all the items.
Input
The first line gives .
Output
Print the minimum number of baskets needed to hold all the items on the first line.