시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
20 초 (추가 시간 없음) | 1024 MB | 23 | 17 | 16 | 72.727% |
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.
2 2 1 1 1 5 1 3 2 3 2 3
Case #1: 1 Case #2: 3
In Sample Case #1, each of the two cups of yogurt will expire in one day. Today, Lucy can consume one of them, but she can only consume at most one cup each day, so she cannot consume both. Tomorrow, Lucy cannot consume the remaining cup of yogurt, because it will have expired.
2 2 2 1 1 6 2 1 1 1 7 7 7
Case #1: 2 Case #2: 5
In Sample Case #1, Lucy can consume up to two cups each day, so she can consume all of the yogurt.
Contest > Google > Kick Start > Google Kick Start 2018 > Round E C번