아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Banana Bunches

시간 제한20초메모리 제한1024 MB

요약
각 값이 K 이하인 음이 아닌 정수 배열에서 합이 정확히 K가 되도록 원소를 골라라. 고른 원소는 최대 두 개의 연속 구간을 이루어야 하며, 개수를 최소로 하라.
난이도

보통10점 중 7점

유형
누적 합, 해시맵, 슬라이딩 윈도우
정답자
아직 제출이 없습니다

문제

Barbara goes to Alan's banana farm, where the NN banana trees are organized in one long line represented by an array BB. The tree at position ii has B_iB\_i banana bunches. Each tree has the same cost. Once Barbara buys a tree, she gets all the banana bunches on that tree. Alan has a special rule: because he does not want too many gaps in his line, he allows Barbara to buy at most 22 contiguous sections of his banana tree line.

Barbara wants to buy some number of trees such that the total number of banana bunches on these purchased trees equals the capacity KK of her basket. She wants to do this while spending as little money as possible. How many trees should she buy?

입력

The first line of the input gives the number of test cases, TT. TT test cases follow.

Each test case begins with a line containing two integers integer NN, the number of trees on Alan's farm, and KK, the capacity of Barbara's basket.

The next line contains NN non-negative integers B_1,B_2,⋯ ,B_NB\_1,B\_2,\cdots,B\_N representing array BB, where the ii-th integer represents the number of banana bunches on the ii-th tree on Alan's farm.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 11) and yy is the minimum number of trees Barbara must purchase to obtain KK banana bunches using at most 22 contiguous sections of the farm, or -1 if it is impossible to do so.

제한

  • 1≤T≤1001 \le T \le 100.
  • 0≤B_i≤K0 \le B\_i \le K, for each ii from 11 to NN.

예제1

  1. 예제 1

    입력
    4
    6 8
    1 2 3 1 2 3
    4 10
    6 7 5 2
    6 8
    3 1 2 1 3 1
    4 6
    3 1 2 0
    
    예상 출력
    Case #1: 3
    Case #2: -1
    Case #3: 4
    Case #4: 3