Under construction

Still being built. Things may change

Packing Files onto Discs

Interview

Time limit5sMemory limit512 MB

Summary
Pack all files onto the fewest discs of capacity X with at most two files per disc.
Level

Medium4 of 10

Topics
Greedy, Two pointers, Sorting
Solved
No attempts yet

Problem

Adam is an organized man, and he has always thought carefully about how to arrange his belongings. He remembers with pleasure the hours of his youth spent moving files from his computer onto compact discs.

Two rules governed that work. First, so that every disc could be labeled clearly, he never placed more than two files on one disc. Second, he never split a single file across several discs. His discs were always large enough to make both rules possible.

Looking back, Adam wonders whether he arranged the files in the best way or wasted a few discs. You are given the capacity of the discs he used (all of his discs had the same capacity) and the list of file sizes he stored. Determine the minimum number of discs needed to store all of the files while obeying both rules.

Input

The first line contains the number of test cases TT. TT test cases follow.

The first line of each test case contains the number of files to be stored NN and the capacity of one disc XX (in MB), separated by a single space. The next line contains the sizes SiS_i (in MB) of the NN files, separated by single spaces.

Limits

  • 1≤T≤1001 \le T \le 100
  • 1≤X≤7001 \le X \le 700
  • 1≤Si≤X1 \le S_i \le X
  • 1≤N≤101 \le N \le 10

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the minimum number of discs needed to store the given files.

Examples3

  1. Example 1

    Input
    3
    3 100
    10 20 70
    4 100
    30 40 60 70
    5 100
    10 20 30 40 60
    
    Expected output
    Case #1: 2
    Case #2: 2
    Case #3: 3
    
  2. Example 2

    Input
    1
    1 1
    1
    
    Expected output
    Case #1: 1
    
  3. Example 3

    Input
    4
    2 700
    350 351
    2 700
    350 350
    4 10
    5 5 5 5
    5 10
    9 1 8 2 10
    
    Expected output
    Case #1: 2
    Case #2: 1
    Case #3: 2
    Case #4: 3