Bits or Brute or ...

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2002, TopCoder, Inc. All rights reserved.

Problem Statement

You are the project manager for your company's largest software development project. You know that the best software has the most code, but there is a limit. Use too much code and your supervisor will say there is bloated code. Given a list of the sizes of various components you could include in the software, and the maximum amount of code you are allowed to have, determine the biggest size the sofware can be (your software must be less than or equal to the maximum). For example:
   sizes = {25,50,60,120} maximum = 130 
Your method will return 120 since all other combinations of components either produce less code, or are greater than the 130 limit. If no software can be built return -1(see last example).

Definition