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

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

Yogurt

면접 대비

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

요약
N개의 요거트 컵의 유통기한 Ai와 하루 최대 섭취량 K가 주어질 때, 오늘부터 먹을 수 있는 요거트의 최대 개수를 구한다.
난이도

보통10점 중 5점

유형
정렬, 그리디, 구현, 배열
정답자
아직 제출이 없습니다

문제

Yogurt can be a nutritious part of an appetizer, main course, or dessert, but it must be consumed before it expires, and it might expire quickly! Moreover, different cups of yogurt might expire on different days.

Lucy loves yogurt, and she has just bought N cups of yogurt, but she is worried that she might not be able to consume all of them before they expire. The i-th cup of yogurt will expire Ai days from today, and a cup of yogurt cannot be consumed on the day it expires, or on any day after that.

As much as Lucy loves yogurt, she can still only consume at most K cups of yogurt each day. What is the largest number of cups of yogurt that she can consume, starting from today?

입력

The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with one line containing two integers N and K, as described above. Then, there is one more line with N integers Ai, as described above.

출력

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 maximum number of cups of yogurt that Lucy can consume, as described above.

제한

  • 1 ≤ T ≤ 100.
  • 1 ≤ K ≤ N.
  • 1 ≤ Ai ≤ 109, for all i.

예제2

  1. 예제 1

    입력
    2
    2 1
    1 1
    5 1
    3 2 3 2 3
    
    예상 출력
    Case #1: 1
    Case #2: 3
    
  2. 예제 2

    입력
    2
    2 2
    1 1
    6 2
    1 1 1 7 7 7
    
    예상 출력
    Case #1: 2
    Case #2: 5