# Algorithm Training Boxing problem

Source: Internet
Author: User

Problem Description
There is a box with a volume of V (positive integer, 0<=v<=20000), and n items (0<n<=30), each with a volume (positive integer).
Requires n items, any number of boxes in the box, so that the remaining space of the box is minimal. Input format first behavior an integer representing the box capacity;
The second act is an integer that indicates that there are n items;
Next n rows, an integer per line represents the respective volume of the N items. An integer in the output format that represents the remaining space of the box.
Sample ExampleInput
24
6
8
3
12
7
9
7 Sample Output 0
`1 ImportJava.math.BigInteger;2 Importjava.util.Arrays;3 ImportJava.util.Scanner;4 5 6  Public classMain {7     Static intN;8     Static int[] A;9     Static intMix = 200000;Ten      Public Static voidMain (string[] args) { OneScanner input =NewScanner (system.in); A         intsum =input.nextint (); -n =input.nextint (); -A =New int[n]; the          for(inti=0;i<n;i++){ -A[i] =input.nextint (); -         } -F (sum,0); + System.out.println (mix); -                  +     } A      Public Static intFintSuminti) { at         if(sum<0)return-1; -         if(i==n) {if(mix>sum) Mix =sum;} -              for(intj=i;j<n;j++){ -                 if(f (sum-a[j],j+1) ==-1){ -                     if(mix>sum) Mix =sum; -                 } in             } -             returnsum; to          +          -          the  *     } \$}`

Algorithm Training Boxing problem

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.