시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
20 초 (추가 시간 없음) | 1024 MB | 3 | 2 | 2 | 66.667% |
The 4M Corporation has hired you to organize their departments and allocate headcount. You will create at least one department, and each department will receive some positive integer number of employees. It will not be easy, though — you have four different bosses, and each has given you a different instruction:
Moreover, for the sake of efficiency, it is best to avoid creating too many departments. What is the smallest number of departments that you can create, if it is possible to satisfy your bosses' requests?
The first line of the input gives the number of test cases, T. T test cases follow. Each consists of four integers: MINIMUM, MAXIMUM, MEAN, and MEDIAN, in that order.
For each test case, output one line containing Case #x: y
, where x
is the test case number (starting from 1), and y
is either the minimum possible number of departments, or IMPOSSIBLE
if it is impossible to satisfy all four bosses' requests.
IMPOSSIBLE
or is less than 14.5 6 4 5 1 7 7 8 8 2 2 2 2 3 7 5 5 1 4 3 4
Case #1: IMPOSSIBLE Case #2: IMPOSSIBLE Case #3: 1 Case #4: 2 Case #5: 3
Sample Case #1 is IMPOSSIBLE
because the maximum value cannot be smaller than the minimum value.
Sample Case #2 is IMPOSSIBLE
because the mean and median cannot be larger than the maximum value.
In Sample Case #3, you can create a single department with 2 employees. This satisfies all four bosses: the department with the fewest employees has exactly 2, the department with the most employees has exactly 2, and the mean and median are both 2.
In Sample Case #4, you can create one department with 3 employees and another department with 7 employees. Note that it would not suffice to create only one department with 5 employees, because then the department with the fewest employees would not have exactly 3 and the department with the most employees would not have exactly 7.
For Sample Case #5, you can create one department with 1 employee and two more departments with 4 employees each.
Contest > Google > Kick Start > Google Kick Start 2017 > Round C D번