This page is still under construction.

Parts of this page are still being built. What you see may change.

Shifts

Time limit40sMemory limit1024 MB

Summary
Count assignments of N shifts, each covered by at least one guard, so that both guards collect at least H happiness in total.
Level

Medium7 of 10

Topics
Dynamic programming, Sorting, Prefix sum, Combinatorics
Solved
No attempts yet

Problem

Aninda and Boon-Nam are security guards at a small art museum. Their job consists of N shifts. During each shift, at least one of the two guards must work.

The two guards have different preferences for each shift. For the i-th shift, Aninda gains Ai happiness points if he works, while Boon-Nam gains Bi happiness points if she works.

The two guards are happy if both of them receive at least H happiness points. How many different assignments of shifts are there where the guards are happy?

Two assignments are considered different if there is a shift where Aninda works in one assignment but not in the other, or there is a shift where Boon-Nam works in one assignment but not in the other.

Input

The first line of the input gives the number of test cases, T. T test cases follow. Each test case begins with a line containing the two integers N and H, the number of shifts and the minimum happiness points required, respectively. The second line contains N integers. The i-th of these integers is Ai, the amount of happiness points Aninda gets if he works during the i-th shift. The third line contains N integers. The i-th of these integers is Bi, the amount of happiness points Boon-Nam gets if she works during the i-th shift.

Output

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the number of different assignments of shifts where the guards are happy.

Limits

  • 1 ≤ T ≤ 100.
  • 0 ≤ H ≤ 109.
  • 0 ≤ Ai ≤ 109.
  • 0 ≤ Bi ≤ 109.

Hint

In Sample Case #1, there are N = 2 shifts and H = 3. There are three possible ways for both Aninda and Boon-Nam to be happy:

  • Only Aninda works on the first shift, while both Aninda and Boon-Nam work on the second shift.
  • Aninda and Boon-Nam work on the first shift, while only Aninda works on the second shift.
  • Both security guards work on both shifts.

In Sample Case #2, there are N = 2 shifts and H = 5. It is impossible for both Aninda and Boon-Nam to be happy, so the answer is 0.

Examples1

  1. Example 1

    Input
    2
    2 3
    1 2
    3 3
    2 5
    2 2
    10 30
    
    Expected output
    Case #1: 3
    Case #2: 0