[Usaco dec07] Bookshelf 2

Source: Internet
Author: User

149. [usaco dec07] Bookshelf 2

★Input file:Shelf2.inOutput file:Shelf2.outSimple comparison
Time Limit: 1 s memory limit: 128 MB

Translated by cmykrgb123

Farmer John recently bought a shelf for the dairy library, and the bottom of the shelf soon filled with books. Now there is only space on the top shelf.

In the N (1 ≤ n ≤ 20) Head ox, the height of the I head ox is hi (1 ≤ Hi ≤ 1,000,000 ). The shelving height is B (1 ≤ B ≤ 2,000,000,007), and B is less than the sum of the heights of all cows.

The top of the shelf is higher than the height of the highest ox, but several cows can stand in one stack, so the total height is the sum of their heights. The total height should be greater than or equal to the height of the bookshelf before the cows can get the books.

But the more cows stand together, the more dangerous they are. Your job is to find the minimum height in which the total height of the cow exceeds the shelf height.

Input

    • Row 1st: two integers: N, B
    • 2nd. n + 1 row: line I + 1 contains an integer hi

Output

    • Row 1st: a non-negative integer. the total height of the cow exceeds the minimum height of the bookshelf.

Sample Input

 
5 1631356

Sample output

 
1
 
 
Simple search
 
 # include 
    
      using namespace STD; int A [22]; int ans, N, B; void DFS (INT cur, int num) {If (Num> = B & num-B> ans) return; If (cur = n + 1) {If (Num> = B & num-B 
     
    

Contact Us

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.