The examples are part of the problem statement and all of them are right. You method doesn't work, take #3 for example:
{1, 1}
{3, 12}
100
27
Returns: 6
Lets say the cost is in $...
each unit costs $1, the first takes 3 sec and the second takes 12 sec. You have a total of $100 to spend and 27 secs. Using you method, you'll make 1 of the first unit, spending $1 and 3 seconds leaving you with $99 and 24 seconds. If you just keep making the 2nd unit from this, you'll only end up with 2 of them. If you make more of the first unit, then they can each simultaneously create the second type of units allowing more to be built in the allotted time.