Rods
InterviewTime limit1sMemory limit1024 MB
Given three rod lengths with limited counts of each, find the fewest rods whose total length reaches at least L, or print 0 if impossible.
- Level
Medium5 of 10
- Topics
- Greedy, Brute force, Math, Implementation
- Solved
- No attempts yet
Problem
We have rods of 3 lengths , , and centimeters, with , , and rods of each length respectively. We must line up some of these rods tightly end to end along their length so that the total length obtained is equal to or greater than centimeters.
Write a program rods that computes the smallest number of rods we can use.
Input
The first line of the standard input contains the given integers in the following order: , , , , , , . The numbers in the input are separated by spaces.
Output
On the first line of the standard output, the program must print one integer equal to the requested count. If it is impossible to line up the rods according to the requirement, your program must print the number 0.
Constraints
All numbers in the input are integers, positive, and less than 100.