Logo
(追記) (追記ここまで)

12202번 - Card Game (Small) 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB41343090.909%

문제

Bob is fond of playing cards. On his birthday party, his best friend Alice gave him a set of cards.

There are N cards and each card contains an integer number. He put the cards from left to right on a desk and wants to discard some of them. Before he discards any cards, he will choose a number K. At each time, he always chooses 3 adjacent cards to discard, and we assume that the numbers on each card from left to right are a, b and c. Bob guarantees that

c - b = b - a = K

Bob want to know what is the smallest number of cards he can be left with at the end. If he ever has a choice of which cards to discard, he chooses the cards and will leave the fewest cards at the end.

입력

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

Each test cases contains two lines. The first line of each test case contains two integers: the number of cards N and the number K Bob chooses. The second line contains N integers a1, a2, ..., aN the numbers on the cards from left to right.

Limits

  • 1 ≤ T ≤ 100.
  • 1 ≤ ai ≤ 106(1 ≤ i ≤ N).
  • 1 ≤ N ≤ 100.
  • K = 0.

출력

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 smallest number of cards Bob can be left with after he has discarded everything he can.

제한

예제 입력 1

2
6 0
4 4 3 3 3 4
5 1
3 1 2 3 4

예제 출력 1

Case #1: 0
Case #2: 2

힌트

출처

Contest > Google > Google's Coding Competitions > Google APAC 2015 University Graduates Test > Round B APAC Test C1번

Contest > Google > Kick Start > Google Kick Start 2014 > Round B C1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /