Rent Division
시간 제한5초메모리 제한2048 MB
각 룸메이트가 낸 기타 비용과 총 월세가 주어질 때, 모든 사람의 총 부담액이 같아지도록 각자의 월세 분담액을 구한다.
문제
In an apartment just down the street from Colorado School of Mines, there are roommates who are trying to figure out how to pay their rent every month. These roommates also have other expenses that they share as well. Rather than using Venmo to share those expenses like sane individuals, they have decided to handle all money exchanges by paying different proportions of rent at the beginning of each month.
For example, let's say there are roommates in an apartment: Jack, Joseph, Jordan, and David. Jack always pays the Internet and utility bills, totalling 81c_1c_2 = c_3 = c_4 = \). Assuming rent this month is 1963R$), how much should each person pay (rounded up), so that each of their total contributions (including expenses that they have already paid) are equal and so that the entire rent is paid?
These roommates are entirely stumped because this is such a difficult calculation. Your mission, if you choose to accept it, is to aid these roommates in finding out what portion of the rent they need to pay individually. If it is not possible, then you should output "not possible", and everyone has to get Venmo. This happens if someone pays too much in other expenses and would need to be paid, rather than pay, rent.
입력
The first line consists of one integer, () which is the number of roommates. The next lines each have one integer () indicating how much person has paid on non-rent expenses.
The last line is the rent due this month, ().
출력
If it is not possible for the total contributions from each roommate to be equal, then output a single line with the words "not possible".
If it is possible for each of the roommates to make an equal total contribution, then output lines each with an integer, , indicating how much of the rent the corresponding person, person , should pay.